在第一次尝试使用 WCF 失败后,客户端如何尝试重新连接到服务器?
我正在使用客户端-服务器应用程序。当客户端启动时,他会看到一个登录屏幕。当服务器尚未启动时,对服务器的调用将引发我捕获的异常(EndpointNotFoundException)。我显示一个消息框,告诉用户服务器已离线。当他尝试再次重新连接时,即使服务器在线,也会抛出另一个异常(CommunicationObjectFaultedException)。当新的客户端启动时,他就可以连接到服务器。但之前尝试过的客户端仍然会收到错误。
我现在的问题是,第一个客户端在第一次尝试失败后如何登录,而不必再次启动他的程序。所以我想清除通信通道的故障状态或类似的情况。
提前致谢。
I'm using a client - server app. When a client starts, he gets a login-screen. When the server is not up yet, the call to the server will throw an exception which i catch (EndpointNotFoundException). I show a messagebox telling the user the server is offline. When he tries to reconnect again, it will throw another exception (CommunicationObjectFaultedException), even though the server is online. When a new client starts then, he can connect to the server. But the client who attempted before, still gets the error.
My question now is how can the first client login after a failed first try without having to start his program again. So i want to clear the communicationchannel of its faulted state or something like that.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,您必须在 EndpointNotFoundException 处理程序中调用
Abort
。 这里有一篇文章解释了原因。Basically, you have to call
Abort
in the EndpointNotFoundException handler. Here is an article that explains the reasoning.