I tried using suggestions from other posts for this and still no resolution. When sending a POST request, at certain times it will just begin to freeze and stall. I set up my code as follows and now basically if I cannot figure out why it is freezing, then it needs to timeout, handle the exception and restart the function
Code:For i As Integer = 0 To searchItems.Count - 1 If uri.Scheme = uri.UriSchemeHttps Then Dim request As HttpWebRequest = HttpWebRequest.Create(url) request.Method = "POST" request.ContentLength = data.Length request.ContentType = "application/xml; charset=utf-8" request.Timeout = 20000 Dim writer As New StreamWriter(request.GetRequestStream) Dim postBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(data) writer.Write(postBytes) ***Using oResponse As HttpWebResponse = request.GetResponse()*** ' this is where it freezes Dim reader As New StreamReader(oResponse.GetResponseStream()) responseData = reader.ReadToEnd() reader.Dispose() oResponse.Close() End Using request.Abort() writer.Close() End If End If Next Catch e As WebException If e.Status = WebExceptionStatus.ProtocolError Then ....
Does anyone know if this is a coding error or something else?
Is the problem from the destination server or is it an error from my end?




Reply With Quote