首页 新闻 赞助 找找看

请帮忙看个WCF问题,困扰好久了,感谢感谢

0
悬赏园豆:100 [待解决问题]

错误:System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
System.ServiceModel.Channels.SocketConnection.Write(...)

在客户端向服务器端发送消息时,SocketConnection.Write。这个错误也不是一直出现,是1天内偶尔会有几个。现在使用的是NetTcp长链接,12小时空闲未使用关闭。有个自定义连接池30个。

--------------------------------
System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.7815972'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
--- End of inner exception stack trace ---

Server stack trace:
at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)
at System.ServiceModel.Channels.BufferedConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSendCore(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Ting.MultiTenant.ServiceInterface.IUserInterfaceV2Provider.GetDetailPageV2(String metaObjName, String viewName, String formState, String id, String parentId, String detailViewName, Boolean showCard)
at wcfProxy.Ting_MultiTenant_ServiceInterface_IWcfApi_ClientFactory_.GetDetailPageV2(String metaObjName, String viewName)

chinaspx的主页 chinaspx | 初学一级 | 园豆:6
提问于:2016-09-02 18:18
< >
分享
所有回答(4)
0

也许是网络问题吧,不是提示超时了么

刘宏玺 | 园豆:14020 (专家六级) | 2016-09-03 00:01

不是超时。

System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.7815972'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

可能是网络问题出现包问题,也可能是TCP通道状态变更时产生的,现在不确定,也模拟不出来,极偶尔才出现。

 

支持(0) 反对(0) chinaspx | 园豆:6 (初学一级) | 2016-09-03 06:19

@chinaspx: 检查下服务端压力(线程数),中间负载均衡是否开启了自动关闭连接等类似机制。

支持(0) 反对(0) Daniel Cai | 园豆:10424 (专家六级) | 2016-09-05 13:20
0

网络掉包 可以用 ping -t ip 测测

或把 netTcpBinding的

listenBacklog和maxConnections 配置大点,如 500 ,200

试试

Yu | 园豆:12980 (专家六级) | 2016-09-03 08:52

这2个值从开始用服务器端配置一直是1000。并且我之前测试了,故意将这2个值设置小,客户端多线程并发调用,是报错,但这不是这个错误(及不是我问的这个问题)。

我现在怀疑是服务器端在关闭空闲连接时,客户端正好调用,但我模拟了,也没模拟出来这个错误。

所以现在这个错误还是未知,因为这是极偶尔在不知道什么情况下出现的。

支持(0) 反对(0) chinaspx | 园豆:6 (初学一级) | 2016-09-03 19:19

StackOverflow 也没有理人呀,my god.

支持(0) 反对(0) chinaspx | 园豆:6 (初学一级) | 2016-09-03 19:20
0

每次调用WCF时,有没有及时关闭释放信道。

CharlesShang | 园豆:202 (菜鸟二级) | 2016-09-12 09:46
0

你写一个简单的例子,~client for 循环(1000) 请求server,不要关闭信道, 看是不是也报这个错误

在不改任何配置下  我记得在第400次请求的时候 就会挂了,如果关闭信道,可以一直循环下去

iDream | 园豆:121 (初学一级) | 2016-09-14 14:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册