WebService Asyc Bug (SP1)

C

Chris Mullins

I'm running on the Windows CE Emulator with VS.NET 2003. I installed SP1 of
the Compact Framework onto the emulator.

I'm calling web services asychronously from the Compact Framework. There
seems to be a limit of 2 simultanious Asych methods running at once before
calls that I make to the Web Service block inside the Compact Framework.

The exact behavior that I see is:
- call Async method 1 (using the BeginXXX method name)
- call Async method 2 (using the BeginXXX method name)
- call method (sync or async). This call will NOT leave the compact
framework until one of the two Async methods has completed. As soon as
either of the Async methods completes, the call with execute and things will
proceed.

I've tried calling the Sync method from my own (manually created) background
thread with no avail.

The code to duplicate this behavior is:
(WEB Service code)
---------------------------------
<WebMethod()> _
Public Function LongRunningMethod() As String
System.Threading.Thread.Sleep(30 * 1000)
Return "LongRunningMethod"
End Function
<WebMethod()> _
Public Function QuickMethod() As String
Return "QuickMethod"
End Function

Compact Framework Code:
----------------------------------
Private _s As New WebReference.Service1
Private Sub Button1_Click(...) Handles Button1.Click
_s.BeginLongRunningMethod(AddressOf callback, Nothing)
_s.BeginLongRunningMethod(AddressOf callback, Nothing)
Dim r As String = _s.QuickMethod() '*** THIS LINE DOES NOT RUN
Debug.WriteLine(r)
End Sub

Private Sub callback(ByVal ar As IAsyncResult)
Dim s As String = _s.EndLongRunningMethod(ar)
Debug.WriteLine(s)
End Sub

When I put a breakpoint on the "QuickMethod" in the Web Service, I don't hit
the breakpoint until one of the two long-running web service calls has
completed. This tells me the problem is on the Compact Framework side, not
on the Web Service side.
 
C

Chris Mullins

Yea, I'm sure it's happinging on the CF.

My initial inclination was that I had a threading-bug in the Web Service, as
I couldn't believe the Compact Framework had a limitation like this. It took
me a while to narrow it down, but it's a for-sure thing.

I testing using Win2003 Server, and Win2K server as well as my XP-Pro
workstation. All have the same symptoms.
 
M

Mike Boilen [MS]

This is a subtle feature of the HttpWebRequest class (on top of which the
web services run). If you check out the documentation for
ServicePoint.ConnectionLimit:

The ConnectionLimit property sets the maximum number of connections that
the ServicePoint can make to an Internet resource. The value of the
ConnectionLimit property is set to the value of the
ServicePointManager.DefaultConnectionLimit property when the ServicePoint
is created; subsequent changes to DefaultConnectionLimit have no effect on
existing ServicePoint instances.

This applies to both synchronous and asynchronous requests, and the
behavior is similar on the desktop (it isn't quite the same because of
Connection Groups). The reason for this behavior is from section 8.1.4 of
RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt), which is the "spec" for
HTTP:

Clients that use persistent connections SHOULD limit the number of
simultaneous connections that they maintain to a given server. A
single-user client SHOULD NOT maintain more than 2 connections with
any server or proxy.

If you really need to have more requests in flight at the same time, then
you should adjust this property on the service point for your server, or
change the value of the ServicePointMangager.DefaultConnectionLimit before
making any requests.

Mike Boilen
Developer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.gotdotnet.com/team/netcf/FAQ.aspx

--------------------
| From: "Chris Mullins" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: WebService Asyc Bug (SP1)
| Date: Mon, 25 Aug 2003 14:15:48 -0700
| Lines: 94
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: dcn242-16.dcn.davis.ca.us 168.150.242.16
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:31927
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Yea, I'm sure it's happinging on the CF.
|
| My initial inclination was that I had a threading-bug in the Web Service,
as
| I couldn't believe the Compact Framework had a limitation like this. It
took
| me a while to narrow it down, but it's a for-sure thing.
|
| I testing using Win2003 Server, and Win2K server as well as my XP-Pro
| workstation. All have the same symptoms.
|
| --
| Chris Mullins
|
| | > Are you sure the blocking is happening at the CF and not at the server
| > hosting the webservices? Might be hard to check but non-server IIS has
| > limits on the number of connections it can maintain.
| >
| > Shaun
| >
| >
| > | > > I'm running on the Windows CE Emulator with VS.NET 2003. I installed
SP1
| > of
| > > the Compact Framework onto the emulator.
| > >
| > > I'm calling web services asychronously from the Compact Framework.
There
| > > seems to be a limit of 2 simultanious Asych methods running at once
| before
| > > calls that I make to the Web Service block inside the Compact
Framework.
| > >
| > > The exact behavior that I see is:
| > > - call Async method 1 (using the BeginXXX method name)
| > > - call Async method 2 (using the BeginXXX method name)
| > > - call method (sync or async). This call will NOT leave the compact
| > > framework until one of the two Async methods has completed. As soon as
| > > either of the Async methods completes, the call with execute and
things
| > will
| > > proceed.
| > >
| > > I've tried calling the Sync method from my own (manually created)
| > background
| > > thread with no avail.
| > >
| > > The code to duplicate this behavior is:
| > > (WEB Service code)
| > > ---------------------------------
| > > <WebMethod()> _
| > > Public Function LongRunningMethod() As String
| > > System.Threading.Thread.Sleep(30 * 1000)
| > > Return "LongRunningMethod"
| > > End Function
| > > <WebMethod()> _
| > > Public Function QuickMethod() As String
| > > Return "QuickMethod"
| > > End Function
| > >
| > > Compact Framework Code:
| > > ----------------------------------
| > > Private _s As New WebReference.Service1
| > > Private Sub Button1_Click(...) Handles Button1.Click
| > > _s.BeginLongRunningMethod(AddressOf callback, Nothing)
| > > _s.BeginLongRunningMethod(AddressOf callback, Nothing)
| > > Dim r As String = _s.QuickMethod() '*** THIS LINE DOES NOT RUN
| > > Debug.WriteLine(r)
| > > End Sub
| > >
| > > Private Sub callback(ByVal ar As IAsyncResult)
| > > Dim s As String = _s.EndLongRunningMethod(ar)
| > > Debug.WriteLine(s)
| > > End Sub
| > >
| > > When I put a breakpoint on the "QuickMethod" in the Web Service, I
don't
| > hit
| > > the breakpoint until one of the two long-running web service calls has
| > > completed. This tells me the problem is on the Compact Framework side,
| not
| > > on the Web Service side.
| > >
| > > --
| > > Chris Mullins
| > >
| > >
| >
| >
| > ---
| > Outgoing mail is certified Virus Free.
| > Checked by AVG anti-virus system (http://www.grisoft.com).
| > Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003
| >
| >
|
|
|
 

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