Hi All,
I'm seeing the 'System.Net.WebException: The operation
has timed out a System.Net.HttpWebRequest.GetResponse() ' error very
often. I had googled 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>
Please let me know what I'm missing.