简体   繁体   English

断开WCF客户端中的问题

[英]disconnecting issues in wcf clients

i have a WCF multiple game service.the clients connect to server and call some methods. 我有WCF多个游戏服务。客户端连接到服务器并调用某些方法。 if one client lost connection,how to reconnect to the server?is there any event for connection lost? 如果一个客户端失去连接,如何重新连接到服务器?是否有任何事件导致连接丢失? how server resume its session and return result of method call that was called before disconnection? 服务器如何恢复其会话并返回断开连接之前调用的方法调用的结果? can anyone give me some posts or articles about this issues. 谁能给我一些有关此问题的帖子或文章。 sorry for bad English. 对不起,英语不好。 thanks for help 感谢帮助

Well there are a few different things you can and should do in order to handle issues of this type. 那么,您可以并且应该做一些不同的事情来处理此类问题。

Firstly, you can enable Reliable Sessions . 首先,您可以启用“ 可靠会话” Reliable sessions are based on the WS-ReliableMessageing protocol and can help mask certain failures in messages and transport. 可靠的会话基于WS-ReliableMessageing协议,可以帮助掩盖消息和传输中的某些故障。 There are also retry attempts and timeouts defined in the reliable sessions. 在可靠会话中还定义了重试尝试和超时。

On the client side, there is a property that indicates the status of the connection (Created, Connected, Faulted) but may not be faulted until after a call. 在客户端,有一个属性指示连接状态(“已创建”,“已连接”,“故障”),但可能直到呼叫后才发生故障。 That is one possibility to check. 这是检查的一种可能性。 Then you can dump your client and recreate the object to connect again. 然后,您可以转储客户端并重新创建对象以再次连接。 You will still need to perform try catch blocks and try to recreate your client on faults. 您仍然需要执行try catch块,并尝试在出现故障时重新创建客户端。

The other issue of your results being returned even after being disconnected could be solved by making your service ConcurrencyMode as Reentrant , or InstanceMode as Single . 通过将服务ConcurrencyMode设置为ReentrantInstanceMode设置为Single ,可以解决即使断开连接后仍返回结果的另一个问题。 Here is a CodePlex artcle on why you would use which combination . 这是CodePlex文章,说明了为什么要使用哪种组合

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM