"Ed Sonneveld" <es********@sunbase.nlwrote in message
news:44**********************@news.xs4all.nl...
Hi,
I have hosted my webservice at a hosting company and it has been working
fine for 2 years now. The webservice is called by winforms clients over
the internet, using the proxy class generated by visual studio.
What I do not understand, however, is that sometimes (say 1% of all calls)
are being executed twice on the server side. I notice that because each
call makes an entry in the database. This problem has been around as long
as the webservice exists.
I am sure the webservice is not called twice in the code of the winforms
client. The calling code is very staightforward.
It is important that the webmethods are not executed more than once after
one request, because there are some costs involved for the users of the
application.
Has someone seen this before? Does anyone have a hunch what might be
causing this? Configuration of the webservice, proxy class, IIS etc? Or is
it normal?
I don't see how this can happen without the client side actually issuing the
call twice. By "client side", I don't just mean the WinForms code, I'm
including any client-side network infrastructure, like proxies, etc. Perhaps
there's some sort of "smart proxy" which is outsmarting itself? I'd look at
a number of things:
1) Are the clients all running the same software and the same version of the
software?
2) Are the clients all behind the same network infrastructure, or are some
at different sites or different companies?
3) Is there any correlation between any subset of clients and the duplicate
messages, or is duplication evenly distributed across all clients? For
instance, maybe it's only the clients at one site which are having this
problem.
4) Network-wise, on a given connection, TCP/IP is meant to prevent the same
bytes being delivered twice. You say you're seeing a web service operation
called twice (ever more than twice, BTW?) This implies that the bytes making
up the call are being delivered more than once, which, if TCP/IP is working,
should not happen _on the same connection_. So, maybe something is
duplicating the connection and the bytes sent on it.
5) Are you ever getting any errors which suggest that only _some_ of the
bytes are being duplicated? I don't know if there are any ASP.NET counters
for this, but it would be interesting if the duplication is of part of a
message as opposed to being of an entire message.
Finally, if you can't solve this problem, or if it's not worth the time to
solve it, you could consider working around it. Have each client-side
request generate a GUID and a timestamp, and maybe some identifying
information about the client machine, and have them both sent with the
request. Record all in the database for debugging purposes, but use the GUID
to determine if the request is a duplicate. Unless the client-side is
issuing the request twice (fat fingers hitting a Submit button twice, for
instance), then you should be safe in ignoring (and flagging!) any request
with the same GUID as one already in the database. If your database code is
set up correctly, the absence of a given GUID in the database would be proof
that this is the original request; the presence would mean that it is a
duplicate and can be logged, and ignored.
I'd also throw an exception to get an error back to the client, who might
then complain about it, thereby uniquely identifying himself... ;-)
Good luck. This sort of thing can be fun if you like mysteries.
John