Last post May 04, 2010 04:17 PM by rcirigiri
May 03, 2010 04:35 PM|rcirigiri|LINK
I know this has been asked umpteen times but i cant find an answer to
Very simply, i have a webservice client which is trying to call a webservice. The webservice may take any time from 5mins to 30mins (or more) for downloading message data from pop3 server . However after 2mins i get the following error:
System.Net.WebException: The operation has timed-out
This is an issue with the webservice client timing out calling the webservice - as
the underlying webservice still runs in the background
Sequence osf steps when the error occurs:
1.User logins with his credentials
2.Webservice client calls webservice to connect to pop3 server and download messages for that particular user.
Code in webservice for downloading data from pop3 server where the exception occurs
private string ReadOutput(bool bMultiline)
StreamReader srReader = new StreamReader(conn);
string strRet = srReader.ReadLine();
// Example #4: Append new text to an existing file
string strLine = "";
// In a multiline message the . indicates end of message
if (strLine == ".")
// Relay will convert any line with just a . in it to ..
if (strLine == "..")
strLine = ".";
strRet += "\r\n" + strLine;
catch (Exception e)
3.Exception is caught in webservice client while webservice continues to run.This exception occurs only when the user receives a large message may be above 1mb because i tested with 1MB msg file where i dint have any problem receiving or downloading from
pop3 server where as with 5 MB message file i got this exception .
After going through couple of forums i tested my luck by changing web.config in both webservice and webservice client where i set the attribute of httpruntime Execution timeout to 300 seconds with no success <httpRuntime
Guys Any Ideas in solving this issue.
Note: I have this webservice client and webservice running on localmachine(OS-Windows Vista)
May 03, 2010 06:15 PM|jimmy q|LINK
Are there any specific errors in the server event log?
Are you using WCF or ASMX?
You can try specifying the max size of a file through WCF and ASMX in the configuration file.
ASMX is like ASP.NET so in the following node
WCF is within the binding element.
May 04, 2010 08:30 AM|rcirigiri|LINK
There are no specific errors in the server event log.The web app which uses the webservice is throwing that exception.Web service is ASMX Based and iam not using WCF it is just simple asp.net 2.0 website using asmx based webservice.I changed the main web
app web.config and webservice web.config but still the error remains the same.
More Debug Information remember the exception occurs at client side which is a simple web app.
Stack Trace:" at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object parameters)\r\n at RelayService.RelayService.GetMessages(RelaySettings rsSettings) in c:\\Users\\RCirigiri\\AppData\\Local\\Temp\\Temporary ASP.NET Files\\web apps\\6be971d4\\14e427f6\\App_WebReferences.3bbi7i5g.1.cs:line 278\r\n at
PageBase.DownloadEmails(String strSessionKey) in c:\\2.00.07\\Source Code\\Web Apps\\App_Code\\PageBase.cs:line 226"
Message:"The Operation has Time Out"
Any Ideas?.Whts going on?..
May 04, 2010 04:17 PM|rcirigiri|LINK
Finally solved the case after looking through the code where it was reading network stream and building the message i finally caught the culprit it was
String Object.Using String Object for string concatenation created all the trouble Every time you add two strings using + operator, a new string allocation is reserverd in memory and used for this new string. So if we are adding strings
100 times using + operator, there will be 100 new memory allocations and this was the causing delay response from webservice which in turn times out the webservice client. Instead of String Object i used StringBuilder where there will only
be one memory allocation which helped in getting fatser response from webservice.Replacing String object with StringBuilder object helped in solving this case.