开发者

How can I tell that a NetTcp-based WCF connection was interrupted?

开发者 https://www.devze.com 2022-12-23 12:21 出处:网络
A WCF service is based on NetTcpBinding. It may happen that a client silently vanishes, leaving the server without knowledge that it is not connected anymore.

A WCF service is based on NetTcpBinding. It may happen that a client silently vanishes, leaving the server without knowledge that it is not connected anymore.

I'm currently using a thread that pings all connected client to see if they are still alive, and removes disconnected clients.

  • Is a ping thread the correct way to solve the issue, or is there a better, possibl开发者_高级运维y event-based way?
  • Do I have to surround every code that communicates with the client by try/catch and remove it from the list of connected clients additionally?


I believe I found the answer myself.

There is an event OperationContext.Current.Channel.Closing that is fired on faulted as well as closed connections.

0

精彩评论

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

关注公众号