c# - The request was aborted: The operation has timed out -


just wanted add after adding code given in question , did not find error happening again. think garbage collection did trick.

i struggling deal above error. have 2 asp.net web applications. 1 of them treated server , other client. using hessian encoding method handle web requests , responses.

initially , client , server responds each other 100% correctly .but after sometime client stops contact server , , received error:

the request aborted: operation has timed out

i have tried many things found on internet resolve problem. first thing did closing of request , response streams.

then added following properties:

request.keepalive = false; request.timeout = 5000; request.proxy = null;  request.servicepoint.connectionleasetimeout = 5000; request.servicepoint.maxidletime = 5000; 

after added readwritetime out , gc.collect().

but efforts ended in no result.

this problem occurs on of godaddy server , project working aboslutely fine on local server , of physical server. not error when running projects localhost.

it occured when deploy godaddy server or connect local client godaddy server.

from log can see request stops reaching server end.

here final code:

// send request edge server. receive response encoded stream         string infomessage = "userid is: " + request.info.userid.asstring() + " session id is: " + request.info.sessionid.asstring();         string logmessage = "inside invoke: " + infomessage;         stream requeststream = null;         httpwebresponse webresponse = null;         stream responsestream = null;          httpwebrequest webrequest=null;         try         {             // construct web request             logmessage = "creating webrequest to: " + url + " " + infomessage;             webrequest = (httpwebrequest)webrequest.create(url);             webrequest.contenttype = encodertype.trim().tolower();             webrequest.method = request_method;             webrequest.timeout = 120000;             webrequest.readwritetimeout = 120000;             webrequest.keepalive = false;             webrequest.proxy = null;             webrequest.servicepoint.connectionleasetimeout = 5000;             webrequest.servicepoint.maxidletime = 5000;             logmessage = logmessage + "timeout 5000 keep alive false";               logmessage = "timout is: " + webrequest.timeout.tostring() + logmessage;             // encode request object stream             requeststream = webrequest.getrequeststream();             encoderfactory.getinstance(this.encodertype).encode(requeststream, request);             logmessage = "going getresponse" + logmessage;             webresponse = (httpwebresponse)webrequest.getresponse();             logmessage = "response returend" + logmessage;             // recieve web response             string contenttype = webresponse.contenttype;             logmessage = "going response stream" + logmessage;             responsestream = webresponse.getresponsestream();              // if response content type 'text/html' assume it's error message             if (contenttype.tolower().trim().startswith("text/html"))             {                 streamreader reader = new streamreader(responsestream, encoding.default);                 string errormessage = reader.readtoend();                 reader.close();                 return new errorresponse(-1000, logmessage + " " + errormessage);             }             else if (contenttype.tolower().trim().startswith(encoderfactory.encoder_type_hessian))             {                 // decode response object stream                 return (response)encoderfactory.getinstance(this.encodertype).decode(responsestream);             }             else             {                 return new errorresponse(-1001, "invalid response - contenttype='" + contenttype + "'");             }         }         catch (exception ex)         {              return new errorresponse(-1002, "exception -1002 , message = " + ex.message + " " + logmessage + ".");         }                 {              // close request stream             if (requeststream != null)             {                 try                 {                     requeststream.flush();                     requeststream.close();                 }                 catch { }             }              // close web response             if (webresponse != null)             {                 try                 {                     webresponse.close();                 }                 catch { }             }              // close response stream             if (responsestream != null)             {                 try                 {                     responsestream.flush();                     responsestream.close();                 }                 catch { }             }             gc.collect();         }     } 


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -