Eventually WCF duplex Silverlight 4 client start getting 404 Not Found
errors for poll messages, immediately after poll was send from WCF service to Silverlight
While investigating issue described on this StackOverflow post Static constructor called twice for PerSession WCF service I found that Polling Duplex
start working stable when I switched IIS
configuration for underlying AppPool
to use single worker process rather than 2
as was specified before. I'm not sure why 2
was set before since I do not own this server, but anyway this is what I have now - multiple Silverlight clients launched on the same machine works stable and polls polls polls and no 404
errors, all clients reconnects in 1
attempt after IIS restarts and recycles...
See Performance Application Pool Settings for more details
TL;DR: When IIS hosted WCF resides in AppPool which has more than one worker process - polling duplex becomes unstable. So in case of high load IIS started second process and start creating WCF service instances in second process as well, so I ran into situation when client session was created in one process but it seems poll sometimes reached an other process whcih is not aware of current connection/session so start refusing such messages and entire connection fault.
So Polling Duplex by design is not scalable across multiple processes in scope of a single IIS server and AppPool, in other words if you have more than 1 worker process - this is WebGarden environment and duplex is not scalable across web farms and gardens
If everything seems to be working fine, then perhaps this is a network infrastructure/configuration issue (e.g. dns configuration). Do you get the same issue when running locally or using ip address instead of host name?
Similar issue may also occur if you have several bindings configured on Site in IIS (see here for details: http://blogs.msdn.com/b/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx)
Another thing is how do you communicated from server to clients. If you iterate clients in a loop and call callback methods one by one, then you may get timeouts which would show as 404s. Callback generally should be invoked on background threads instead (one per client).
Depending on how you do the communication, this may also be caused by the deadlock (when UI thread is involved in sending/receiving messages/callbacks to and from service).