Posting data to webpage in a loop

M

Mike

I am posting data in a loop. Looping 25 times works. Looping 99 times
doesn't work. I have looked at the free memory and free memory is actually
higher when it fails than when it started. Why would posting data fail on
the 50th time of doing the same thing over and over?

Here is the post code:

Dim req As System.Net.HttpWebRequest

Dim bPostData() As Byte

Dim Stream1 As System.IO.Stream

Dim resp As System.Net.WebResponse

req = Utils.CreateWebRequest(VsURL)

req.Method = "POST"

req.ContentType = "application/x-www-form-urlencoded"
' Encode the data

bPostData = System.Text.Encoding.UTF8.GetBytes(VsPost)

req.ContentLength = bPostData.Length



' Write encoded data into request stream

Stream1 = req.GetRequestStream()

Stream1.Write(bPostData, 0, bPostData.Length)

Stream1.Close()

resp = req.GetResponse()

Dim myStream As System.IO.Stream = resp.GetResponseStream()

Dim encode As System.text.Encoding =
System.Text.Encoding.GetEncoding("utf-8")

' Pipe the stream to a higher level stream reader with the required encoding
format.

Dim readStream As New System.IO.StreamReader(myStream, encode)

Dim strResponse As String = readStream.ReadToEnd()

' Release the resources of stream object.

readStream.Close()

' Close the response to free resources.

resp.Close()
 
G

Guest

What error message are you getting? Is your webserver refusing the posted data? Maybe try to force garbage collection

....Mark Arteag

----- Mike wrote: ----

I am posting data in a loop. Looping 25 times works. Looping 99 time
doesn't work. I have looked at the free memory and free memory is actuall
higher when it fails than when it started. Why would posting data fail o
the 50th time of doing the same thing over and over

Here is the post code

Dim req As System.Net.HttpWebReques

Dim bPostData() As Byt

Dim Stream1 As System.IO.Strea

Dim resp As System.Net.WebRespons

req = Utils.CreateWebRequest(VsURL

req.Method = "POST

req.ContentType = "application/x-www-form-urlencoded
' Encode the dat

bPostData = System.Text.Encoding.UTF8.GetBytes(VsPost

req.ContentLength = bPostData.Lengt



' Write encoded data into request strea

Stream1 = req.GetRequestStream(

Stream1.Write(bPostData, 0, bPostData.Length

Stream1.Close(

resp = req.GetResponse(

Dim myStream As System.IO.Stream = resp.GetResponseStream(

Dim encode As System.text.Encoding
System.Text.Encoding.GetEncoding("utf-8"

' Pipe the stream to a higher level stream reader with the required encodin
format

Dim readStream As New System.IO.StreamReader(myStream, encode

Dim strResponse As String = readStream.ReadToEnd(

' Release the resources of stream object

readStream.Close(

' Close the response to free resources

resp.Close(
 
M

Mike

I'm getting a WebException with Message = "Unable to connect to the remote
server.". I'll try the garbage collector.

Mark Arteaga said:
What error message are you getting? Is your webserver refusing the posted
data? Maybe try to force garbage collection.
 
G

Guest

If you can't connect to the server then maybe it's a server issue. When you get that error try and connect with a browser to your server and see what happens. Server may have reached the max allowed connections

....Mar

----- Mike wrote: ----

I'm getting a WebException with Message = "Unable to connect to the remot
server.". I'll try the garbage collector

Mark Arteaga said:
What error message are you getting? Is your webserver refusing the poste
data? Maybe try to force garbage collection
 
M

Mike

Garbage collector didn't help.

On the Pocket PC after the error, I can't connect to any websites in Pocket
IE. If I pull the PPC out of the cradle, wait a few secs, then put it back
in the cradle, then I can connect to websites again. Maybe some limit is
being reached in the ActiveSync client? (I'm assuming web requests go
through ActiveSync)


Mark Arteaga said:
If you can't connect to the server then maybe it's a server issue. When
you get that error try and connect with a browser to your server and see
what happens. Server may have reached the max allowed connections.
 
M

Mike

Here is the end of my wcescomm.log on my PC after the exception occurs:

03/19/2004 15:44:53.108 - TCP: ....S., 192.168.55.101(1806) =>
209.114.200.175(80) Seq=1146225527-1146225527 Ack=0 Win=32768 Len=48
03/19/2004 15:44:53.108 - TCP: .A..S., 209.114.200.175(80) =>
192.168.55.101(1806) Seq=98340736-98340736 Ack=1146225528 Win=8760 Len=44
03/19/2004 15:44:53.128 - TCP: ...R.., 192.168.55.101(1805) =>
209.114.200.175(80) Seq=1145639284-1145639284 Ack=1145639284 Win=0 Len=40
03/19/2004 15:44:53.228 - CesProxy: End of stream, PPP socket 80
03/19/2004 15:44:53.228 - CesProxy: Shutdown PPP socket 80
03/19/2004 15:44:53.829 - CesProxy: Accept on port 80, IsWinsock 0, hResult
0
03/19/2004 15:44:55.912 - CesProxy: End of stream, Win socket 80
03/19/2004 15:44:55.922 - CesProxy: Shutdown PPP socket 80
03/19/2004 15:44:55.922 - TCP: .A...F, 209.114.200.175(80) =>
192.168.55.101(1806) Seq=98340990-98340990 Ack=1146228325 Win=8760 Len=40
03/19/2004 15:44:56.032 - TCP: .A...F, 192.168.55.101(1806) =>
209.114.200.175(80) Seq=1146228325-1146228325 Ack=98340991 Win=32515 Len=40
03/19/2004 15:44:56.213 - TCP: ....S., 192.168.55.101(1807) =>
209.114.200.175(80) Seq=1147058668-1147058668 Ack=0 Win=32768 Len=48
03/19/2004 15:44:56.233 - TCP: .A..S., 209.114.200.175(80) =>
192.168.55.101(1807) Seq=98343860-98343860 Ack=1147058669 Win=8760 Len=44
03/19/2004 15:44:56.253 - TCP: ...R.., 192.168.55.101(1806) =>
209.114.200.175(80) Seq=1146228326-1146228326 Ack=1146228326 Win=0 Len=40
03/19/2004 15:44:56.343 - CesProxy: End of stream, PPP socket 80
03/19/2004 15:44:56.353 - CesProxy: Shutdown PPP socket 80
03/19/2004 15:44:57.094 - CesProxy: Accept on port 80, IsWinsock 0, hResult
0
03/19/2004 15:44:58.296 - CesProxy: End of stream, Win socket 80
03/19/2004 15:44:58.296 - CesProxy: Shutdown PPP socket 80
03/19/2004 15:44:58.306 - TCP: .A...F, 209.114.200.175(80) =>
192.168.55.101(1807) Seq=98344114-98344114 Ack=1147061466 Win=8760 Len=40
03/19/2004 15:44:58.416 - TCP: .A...F, 192.168.55.101(1807) =>
209.114.200.175(80) Seq=1147061466-1147061466 Ack=98344115 Win=32515 Len=40
03/19/2004 15:44:58.596 - TCP: ....S., 192.168.55.101(1808) =>
209.114.200.175(80) Seq=1147702800-1147702800 Ack=0 Win=32768 Len=48
03/19/2004 15:44:58.616 - TCP: .A..S., 209.114.200.175(80) =>
192.168.55.101(1808) Seq=98346244-98346244 Ack=1147702801 Win=8760 Len=44
03/19/2004 15:44:58.636 - TCP: ...R.., 192.168.55.101(1807) =>
209.114.200.175(80) Seq=1147061467-1147061467 Ack=1147061467 Win=0 Len=40
03/19/2004 15:44:58.726 - CesProxy: End of stream, PPP socket 80
03/19/2004 15:44:58.736 - CesProxy: Shutdown PPP socket 80
03/19/2004 15:44:59.267 - CesProxy: Accept on port 80, IsWinsock 0, hResult
0
03/19/2004 15:45:00.419 - CesProxy: End of stream, Win socket 80
03/19/2004 15:45:00.429 - CesProxy: Shutdown PPP socket 80
03/19/2004 15:45:00.429 - TCP: .A...F, 209.114.200.175(80) =>
192.168.55.101(1808) Seq=98346498-98346498 Ack=1147705596 Win=8760 Len=40
03/19/2004 15:45:00.539 - TCP: .A...F, 192.168.55.101(1808) =>
209.114.200.175(80) Seq=1147705596-1147705596 Ack=98346499 Win=32515 Len=40
03/19/2004 15:45:00.929 - TCP: ....S., 192.168.55.101(1809) =>
209.114.200.175(80) Seq=1148333491-1148333491 Ack=0 Win=32768 Len=48
03/19/2004 15:45:00.929 - TCP: .A.R.., 209.114.200.175(80) =>
192.168.55.101(1809) Seq=0-0 Ack=1148333492 Win=0 Len=40
03/19/2004 15:45:01.420 - TCP: ....S., 192.168.55.101(1809) =>
209.114.200.175(80) Seq=1148333491-1148333491 Ack=0 Win=32768 Len=48
03/19/2004 15:45:01.420 - TCP: .A.R.., 209.114.200.175(80) =>
192.168.55.101(1809) Seq=0-0 Ack=1148333492 Win=0 Len=40
03/19/2004 15:45:01.440 - TCP: ...R.., 192.168.55.101(1808) =>
209.114.200.175(80) Seq=1147705597-1147705597 Ack=1147705597 Win=0 Len=40
03/19/2004 15:45:01.550 - CesProxy: End of stream, PPP socket 80
03/19/2004 15:45:01.550 - CesProxy: Shutdown PPP socket 80
03/19/2004 15:45:01.931 - TCP: ....S., 192.168.55.101(1809) =>
209.114.200.175(80) Seq=1148333491-1148333491 Ack=0 Win=32768 Len=48
03/19/2004 15:45:01.931 - TCP: .A.R.., 209.114.200.175(80) =>
192.168.55.101(1809) Seq=0-0 Ack=1148333492 Win=0 Len=40
03/19/2004 15:45:02.331 - TCP: ....S., 192.168.55.101(1809) =>
209.114.200.175(80) Seq=1148333491-1148333491 Ack=0 Win=32768 Len=48
03/19/2004 15:45:02.341 - TCP: .A.R.., 209.114.200.175(80) =>
192.168.55.101(1809) Seq=0-0 Ack=1148333492 Win=0 Len=40
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top