Socket connection was aborted - WCF

廉价感情. 提交于 2019-12-10 22:28:55

问题


I have a simple client server apps that uses WCF (netTcpBinding) when i'm launching the server and sending messages through the client everythings works fine , but when i'm closing the server manually and open it again (without closing the client app at all) the next time the client tries to send a message to the server i get this exception (on the client side):

The socket connection was aborted. This could be caused by an error processing y our message or a receive timeout being exceeded by the remote host, or an underl ying network resource issue. Local socket timeout was '00:00:59.9843903'.

if i use basicHttpBinding the problem doesn't occur.

is any one knows why this problem occurs ??? Thanks, Liran


回答1:


This is expected behavior. When you close the server, TCP connection on the server is closed and you can't call it from the client anymore. Starting the server again will not help. You have to catch the exception on the client, Abort current proxy and create and open new one.

With BasicHttpBinding it works because NetTcpBinding uses single channel for whole life of the proxy (the cannel is bound to TCP connection) whereas BasicHttpBinding creates new one for each call (it reuses existing HTTP connection or create new one if connection doesn't exist).



来源:https://stackoverflow.com/questions/3652278/socket-connection-was-aborted-wcf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!