Posting data in a loop

M

Mike

In my Smart Device Application, I am posting data in a loop. Looping 25
times works. Looping 99 times
doesn't work. I have looked at the free memory on the device 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()
 
M

Mike

I'm getting a WebException with Message = "Unable to connect to the remote
server.". I'll try the garbage collector.
 
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
 
M

Mike

This code reproduces the error on a device. The exception doesn't happen on
the emulator.

Public Class Form1

Inherits System.Windows.Forms.Form

Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

MyBase.Dispose(disposing)

End Sub

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Private Sub InitializeComponent()

Me.MainMenu1 = New System.Windows.Forms.MainMenu

Me.Button1 = New System.Windows.Forms.Button

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(65, 79)

Me.Button1.Size = New System.Drawing.Size(102, 61)

Me.Button1.Text = "Go"

'

'Form1

'

Me.Controls.Add(Me.Button1)

Me.Menu = Me.MainMenu1

Me.Text = "Form1"

End Sub

#End Region



Private Sub PostData(ByVal i As Integer)

Dim req As System.Net.HttpWebRequest

Dim bPostData() As Byte

Dim Stream1 As System.IO.Stream

Dim resp As System.Net.WebResponse, sWhereClause As String

Try

req = System.Net.WebRequest.Create("http://www.4rph.com")

req.Method = "POST"

req.ContentType = "application/x-www-form-urlencoded"

' Encode the data

bPostData = System.Text.Encoding.UTF8.GetBytes("x")

req.ContentLength = bPostData.Length

' Write encoded data into request stream

Stream1 = req.GetRequestStream()

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

Stream1.Close()

resp = req.GetResponse()

resp.Close()

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim i As Integer

For i = 1 To 100

PostData(i)

Next

MsgBox("Done")

End Sub

End Class
 
G

Gary Chang

Hi Mike,

Thanks for you posting in the group!

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.


Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
M

Mike

Adding this line inside the loop seems to prevent the exception from
occurring:

System.Threading.Thread.Sleep(10)
 
M

Mike

However it doesn't prevent the exception if I read the response:

req = System.Net.WebRequest.Create("http://www.4rph.com")
req.Method = "POST"

req.ContentType = "application/x-www-form-urlencoded"

' Encode the data

bPostData = System.Text.Encoding.UTF8.GetBytes("x")

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()

resp.Close()
 
Y

Yan-Hong Huang[MSFT]

Hi Mike,

Currely we have forwarded it to our CE support team. They will look into it
and reply here with more information. It may need some more time. But
please rest assure that we will do our best on it.

Thanks very much for your understanding.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mike

Do you mean that the web server is not persisting the connection?
Regardless of what the web server is doing, the Pocket PC software shouldn't
be acting the way it is. After the exception, you can't connect to the
internet from the Pocket PC anymore until you reset it or disconnect from
the cradle and reconnect.
 
Y

Yan-Hong Huang[MSFT]

Hi Mike,

We tested it on our side. This code reproduces the error on a device. The
exception doesn't happen on the emulator. Currently we are still
researching it and will reply the information here. Thanks very much for
your patience.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mike

Why did you copy what I wrote?

Can you provide me with an incident number and a phone number to get in
touch with CE support? I'd like to find out the status.

Thanks,

Mike W.
 
M

Mike

The problem only seems to happen with ActiveSync v3.7.1. (I get a different
error with v3.7)
 
Y

Yan-Hong Huang[MSFT]

Hi Mike,

We just reprodcued it on our side. So I rementioned it on my reply.

Currently I am working with Global WinCE support team on it. We will reply
here as soon as possible. However, since it is a complicated issue, we need
more time to dig into it. For newsgroup support, we didn't provide one on
one support yet. So there is no incident number. If you want one support
engineer contact you directly in email, you can send email to (remove
"online." from this no Spam email address):
mailto:[email protected] with the following information,

* Include "Followup: <21813254>" in the email Subject.
*Location of the post
*Subject Line
* First Name, Last Name
*MSDN Subscriber ID
*Company name (if any)
*Phone number
*e-mail address

We are glad to create support incident for you based on your MSDN
subscriber ID. You should have 2 free support incidents as a MSDN
subscriber.

Thanks very much for your understanding and please feel free to post here
if there is anything unclear.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

Rashmi Anoop[MSFT]

Hi Mike,

I'm currently working on this and investigating the problem. If there are
any workarounds I'll let you know.

Regards,
Rashmi.
 
R

Rashmi Anoop[MSFT]

Hi Mike,

Thanks for reporting this problem.I don't have more information about the
root cause of this problem. If any information becomes available I'll
update the post.

Regards,
Rashmi.
 

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