Sometimes, a server error "System.Net.WebException: The operation has timed out" is diplayed in my application. This happened when I try to render a report using a PDF format. But I never encounter this error when rendering in EXCEL or HTML format.
In my opinion this occurs when the report to be rendered to huge.
NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,Microsoft cannot make any representations regarding the quality,safety, or suitability of any software or information found there.
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
I'm seeing the same issue...'System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse() ' error very often on our website. We try to log the website visits and log to a differnet box.
I had googled the error and tried several fixes that were suggested, still no luck.
Here is my code.
Dim objStream As System.IO.Stream
Dim objReader As System.IO.StreamReader
Dim objRequest As System.Net.HttpWebRequest
Dim objResponse As System.Net.WebResponse
If Not UserAgent.Equals(String.Empty) Then
objRequest.UserAgent = UserAgent
End If
'Fixes tried 2..no luck
'Get the service point that handles the request's socket connection.
Dim point As ServicePoint = objRequest.ServicePoint
' Set the receive buffer size on the underlying socket.
point.ReceiveBufferSize = 2048
' Set the connection lease timeout to infinite.
point.ConnectionLeaseTimeout = Timeout.Infinite
point.ConnectionLimit = 1000
'Fixes tried 3..no luck
'make sure the stream and response objects are closed to make sure we free the connection
objStream.Close()
objResponse.Close()
objRequest.Abort()
Catch ex As Exception
'adding some more info while logging
Throw New Exception("Unable to log to webtrends" & " URL: " & sbURL.ToString, ex)
Finally
If Not objResponse Is Nothing Then
objResponse = Nothing
End If
If Not objStream Is Nothing Then
objStream = Nothing
End If
drLogInfo = Nothing
objReader = Nothing
End Try
I have also tried to increase mas connections....no luck there too
<system.net>
<connectionManagement>
<add address="*" maxconnection="25" />
</connectionManagement>
</system.net>
I have tried the following setting too....no luck.
gca14
0 Points
2 Posts
System.Net.WebException: The operation has timed out
May 11, 2007 01:39 AM|LINK
Sometimes, a server error "System.Net.WebException: The operation has timed out" is diplayed in my application. This happened when I try to render a report using a PDF format. But I never encounter this error when rendering in EXCEL or HTML format.
In my opinion this occurs when the report to be rendered to huge.
Is there any solution to prevent this error?
Young Fang -...
All-Star
17147 Points
1620 Posts
Re: System.Net.WebException: The operation has timed out
May 15, 2007 02:19 AM|LINK
Hi,
First make sure you close your HTTP connections:
HttpWebRequest r = WebRequest.Create("URL");
HttpWebResponse w = r.GetResponse()
////...........
w.Close(); // Close connection here.
And you can try increasing maxRequestLength int the Httpruntime section in web.config.
For details see: http://support.microsoft.com/kb/821268
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
whatsavailab...
Member
4 Points
2 Posts
Re: System.Net.WebException: The operation has timed out
May 04, 2010 08:24 PM|LINK
Hi All,
I'm seeing the same issue...'System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse() ' error very often on our website. We try to log the website visits and log to a differnet box.
I had googled the error and tried several fixes that were suggested, still no luck.
Here is my code.
Dim objStream As System.IO.Stream
Dim objReader As System.IO.StreamReader
Dim objRequest As System.Net.HttpWebRequest
Dim objResponse As System.Net.WebResponse
Try
objRequest = CType(System.Net.WebRequest.Create(sbURL.ToString), System.Net.HttpWebRequest)
objRequest.Timeout = TimeOutInMilliseconds
'Fixes tried 1..no luck
objRequest.KeepAlive = False
If Not UserAgent.Equals(String.Empty) Then
objRequest.UserAgent = UserAgent
End If
'Fixes tried 2..no luck
'Get the service point that handles the request's socket connection.
Dim point As ServicePoint = objRequest.ServicePoint
' Set the receive buffer size on the underlying socket.
point.ReceiveBufferSize = 2048
' Set the connection lease timeout to infinite.
point.ConnectionLeaseTimeout = Timeout.Infinite
point.ConnectionLimit = 1000
objResponse = objRequest.GetResponse
objStream = objResponse.GetResponseStream
objReader = New System.IO.StreamReader(objStream)
strPageContents = objReader.ReadToEnd
CURRENT_CONTEXT.Trace.Write("Response Contents", strPageContents)
objReader.Close()
'Fixes tried 3..no luck
'make sure the stream and response objects are closed to make sure we free the connection
objStream.Close()
objResponse.Close()
objRequest.Abort()
Catch ex As Exception
'adding some more info while logging
Throw New Exception("Unable to log to webtrends" & " URL: " & sbURL.ToString, ex)
Finally
If Not objResponse Is Nothing Then
objResponse = Nothing
End If
If Not objStream Is Nothing Then
objStream = Nothing
End If
drLogInfo = Nothing
objReader = Nothing
End Try
I have also tried to increase mas connections....no luck there too
<system.net>
<connectionManagement>
<add address="*" maxconnection="25" />
</connectionManagement>
</system.net>
I have tried the following setting too....no luck.
System.Net.ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit
or System.Net.ServicePointManager.DefaultConnectionLimit = 1000
Please let me know what I'm missing.