Click here to Skip to main content
15,860,861 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi all, I ran into a problem the other day when the deployed started freezing up after a few database calls, where this didn't happen while in VS 2012, after a while I realized that each time a call was made a new connection was added to the connection pool. this is where im a bit stuck. To my understanding if the connection string stays the same its supposed to use the same connection already open in the pool , but this calls kept opening new connections until the pool was full, and there my app was sitting waiting for a connection to become available.

I have a little javascript class that makes syncronous calls rather async,
looks like this
JavaScript
DTMS.Web.Data.SynchronousJSONCall = function(location) {
    this._requestObject = window.XMLHttpRequest ? new XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("MSXML2.XMLHTTP.3.0") : "";
    if (this._requestObject == "")
        throw "Cannot Load XMLHttpRequest";
    this._Content_Type = "application/json; charset=utf-8";
    if (location)
        this._location = location + '/';
    else
        this._location = "http://" + window.location.host + (window.location.pathname.indexOf('.aspx') != -1 ? window.location.pathname : window.location.pathname + 'Default.aspx') + "/";
    this._Method = null;
    this._parameters = null;
}

DTMS.Web.Data.SynchronousJSONCall.prototype = {
    send: function(methodName, Parameters) {
        this._Method = methodName;
        this._parameters = Parameters;
        ////
        this._requestObject.open("POST", this._location + methodName, false);
        this._requestObject.setRequestHeader("Content-Type", this._Content_Type);
        this._requestObject.send(Parameters);
        var result = Sys.Serialization.JavaScriptSerializer.deserialize(this._requestObject.responseText, false);
        if (typeof (result.d) != 'undefined')
            return result.d;
        else
            throw result.Message;
    }
}


i instantiate the class and then call send with my method to call and parameters to send with,
on the C# side its a static [WebMethod] on the same page the call is done,

I overcame the whole connection pooling thing by adding a webservice page and moving all my static methods to there and made them not static, this seemed to solve the connection pooling thing.

so if anyone could please point me in the right direction as to why when the c# methods are static they add a new connection to the connection pool?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900