datastream.write hangs for long time

  • Thread starter Thread starter Ravnø Data
  • Start date Start date
R

Ravnø Data

Guest
I am sending notifications to smartphones, using code as below:

-------------------------------


Sub sendNotification(S as string)

Dim request As WebRequest = WebRequest.Create("https://xx.yyy.io")
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(S)
request.Method = "POST"
request.ContentType = "application/json"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)

dataStream.Close()
dataStream.Dispose()
byteArray = Nothing
request = Nothing


end sub


---------------------------

S is a json-formatted string

It works fine - notification reaches the smartphone.

But when I call the sub several times eg 4 times in a minute, the third or the forth call hangs in the datastream.write for almost a minute.

Can anyone please explain why - and maybe even what to do ?

mvh ravnø

Continue reading...
 
Back
Top