Problem in DSA WebServiceRequestDispatcher.cs ?

Topics: Mobile Client Software Factory
Aug 9, 2007 at 8:51 PM
In the mobile client software factory I ran into a problem with the Disconneted Service Agent. I ended up modifying the code in WebServiceRequestZDispatcher.cs, but I am concerned my change will have a negative impact that I don't yet understand. Here were the steps:

The problem:
- perform multiple offline web service calls
- dock the mobile unit so it has desktop passthrough internet access
- it seemed that the DSA would fire off my web service calls when it was connected, but desktop passthrough connection was not quite ready.
- this would cause a System.Net.WebExceptionStatus.ReceiveFailure error to be thrown
- in WebServiceRequestDispatcher.cs, there is a section where it catches WebExceptions (line 129) and depending on the web exception will either retry, or fail completely sending the message to the dead letter queue.

My solution:
- add WebExceptionStatus.ReceiveFailure: to the list of "acceptable" web exceptions for a retry.

If anyone happens to read this that has been in this code, or developed by chance and could comment on this that would be great.

Thanks
Oct 5, 2007 at 1:45 AM
We modified other scenarios too.
The DSA for SCSF might have a similar but more mature implementation that might be used as a reference, but I dont know if that one is based on the mobile version at all, but I'm sure there's an option as retry under some circumstances.

Finally you have a Failure Callback where you can decide if you want to retry or no, so if you did the change you could still do something different here depending on the type of requests or scenario you want to handle but if you dont change the DSA your callback will never be called so you won't event have a change to made a different choice.

The right way to do this would be to change the ConnectionMonitor implementation for DesktopConnection to handle properly the connection initialization.

Has your device a CellConnection? Do you have the CellConnectin defined in the app.config?

By the way there's a post with the same issue http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=13793


shaunr wrote:
In the mobile client software factory I ran into a problem with the Disconneted Service Agent. I ended up modifying the code in WebServiceRequestZDispatcher.cs, but I am concerned my change will have a negative impact that I don't yet understand. Here were the steps:

The problem:
- perform multiple offline web service calls
- dock the mobile unit so it has desktop passthrough internet access
- it seemed that the DSA would fire off my web service calls when it was connected, but desktop passthrough connection was not quite ready.
- this would cause a System.Net.WebExceptionStatus.ReceiveFailure error to be thrown
- in WebServiceRequestDispatcher.cs, there is a section where it catches WebExceptions (line 129) and depending on the web exception will either retry, or fail completely sending the message to the dead letter queue.

My solution:
- add WebExceptionStatus.ReceiveFailure: to the list of "acceptable" web exceptions for a retry.

If anyone happens to read this that has been in this code, or developed by chance and could comment on this that would be great.

Thanks

Oct 5, 2007 at 6:09 PM
Edited Oct 5, 2007 at 6:10 PM
Thanks for the information. I will try adding the WebExceptionStatus.ReceiveFailure to the switch. I do agree with mamadero however. It would seem that modifying how the desktop connection is made would be the proper way to do this. I have dug through the code, however, and it is not very apparent to me where to make changes.

How has adding to the switch worked for you so far?
Oct 10, 2007 at 10:06 PM
I have added a Ping method to my web service. All it does is return a DateTime from the server. I subscribe tot he ConnectionStatus changed event. When that even fires, I call the Ping method (directly not trough the DSA). If it's successfull, I then call the StartAutomaticDispach method of the DSA. So far, this has been successfull.

I also recently discovered a property in the SystemState namespace that relates to ActiveSync. It could be used like this:

using Microsoft.WindowsMobile.Status;

if (!SystemState.ActiveSyncStatus == ActiveSyncStatus.Synchronizing)
{
//do nothing
}
else
{
// do something
}

I have not tried this myself (yet) but it seems like it my directly address my original problem.