We migrated code from vb to vb.net. In vb msxml was used to make http requests and in .net we changed to httpwebrequest. With this new implementation an exception is thrown while executing httpwebrequest.getrequeststream.
The exception code is 10060 and the exception message is A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
This exception occurs intermittently and not always.
Please find below the code snippet which i've used to achieve the result
Dim HttpRequest As HttpWebRequest
Dim HttpResponse As HttpWebResponse
Dim streamReader As StreamReader
Dim streamWriter As StreamWriter
HttpRequest = HttpWebRequest.Create(strUrl)
HttpRequest.Method = WebRequestMethods.Http.Post
HttpRequest.ContentType = "text/xml"
HttpRequest.Timeout = 999999999
HttpRequest.ContentLength = Str(Len(temp))
streamWriter = New StreamWriter(HttpRequest.GetRequestStream)
streamWriter.Write(temp)
streamWriter.Flush()
streamWriter.Close()
HttpRequest.GetRequestStream.Close()
HttpResponse = CType(HttpRequest.GetResponse, HttpWebResponse)
streamReader = New StreamReader(HttpResponse.GetResponseStream)
temp = streamReader.ReadToEnd
streamReader.Close()
HttpResponse.Close()
Please advice on a resolution
Thanks,
Anil