开发者

Detect connection failure during an async method call in a WCF service

I have an async WCF service implementation and I want to detect when the client aborts the connection during a WCF method call.

Basically, this is what I want:

  1. Client calls WCF method
  2. Server begins processing the request asynchronously
  3. Client aborts the connection (or the connection fails for whatever reason)
  4. Server should be notified that the client aborted the connection

Is this possible?

This is for a long-polling implementation. Alternatively, can the server make sure that the client received the response successfully? If it didn't,开发者_Go百科 the response should be saved for the next poll request.


I don't know any reliable way of knowing that client is connected or not. See this,this and this

Some of the alternative suggested are to use Duplex channels or use Queues. A Queue based solution would have server posting response to queue and client picking those responses from the queue. The queue can be implemented in MSMQ, DB, Azure.

Thanks


You could set up a polling solution where instead of the client staying connected to wait for an answer, it makes the request and immediately disconnects. It then reconnects every X seconds to poll if the request is completed or not yet.

On the server, if you don't see the client poll for X * 2 seconds, then something happened to the client and you should abort the request.

Making that work is going to require some extra infrastructure on the server to keep track of which requests are active and when you last saw the client, unfortunately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜