【发布时间】:2018-11-17 20:18:39
【问题描述】:
几天来,我们一直遇到 WCF 通信错误,我无法弄清楚是什么导致了该错误。我最初认为这是一个 SSL 证书问题,但事实并非如此。我还确保只需在 Web 浏览器上输入 URL 即可访问端点并且它是可查看的。我还确保默认请求大小不会导致问题。我确定请求小于默认的 30MB。
还有哪些其他方法可以防止此堆栈跟踪错误?
客户端堆栈跟踪:
由于通信失败,WCFDirector 获取失败。
由于表单未正确加载,因此必须将其关闭。 ---> OSI.Framework.FrameworkException: WCFDirector fetch 由于通信失败而失败。 ---> System.ServiceModel.CommunicationException:底层连接已关闭:预期保持活动状态的连接已被服务器关闭。 ---> System.Net.WebException:底层连接已关闭:预期保持活动状态的连接已被服务器关闭。 ---> System.IO.IOException: Unable to read data from the transport connection: 一个现有的连接被远程主机强行关闭。 ---> System.Net.Sockets.SocketException: 现有连接被远程主机强行关闭 在 System.Net.Sockets.Socket.Receive(Byte[] 缓冲区,Int32 偏移量,Int32 大小,SocketFlags socketFlags) 在 System.Net.Sockets.NetworkStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小) --- 内部异常堆栈跟踪结束 --- 在 System.Net.Sockets.NetworkStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小) 在 System.Net.FixedSizeReader.ReadPacket(字节 [] 缓冲区,Int32 偏移量,Int32 计数) 在 System.Net.Security._SslStream.StartFrameHeader(字节 [] 缓冲区,Int32 偏移量,Int32 计数,AsyncProtocolRequest asyncRequest) 在 System.Net.Security._SslStream.StartReading(字节 [] 缓冲区,Int32 偏移量,Int32 计数,AsyncProtocolRequest asyncRequest) 在 System.Net.Security._SslStream.ProcessRead(字节 [] 缓冲区,Int32 偏移量,Int32 计数,AsyncProtocolRequest asyncRequest) 在 System.Net.TlsStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小) 在 System.Net.PooledStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小) 在 System.Net.Connection.SyncRead(HttpWebRequest 请求,布尔 userRetrievedStream,布尔 probeRead) --- 内部异常堆栈跟踪结束 --- 在 System.Net.HttpWebRequest.GetResponse() 在 System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan 超时) --- 内部异常堆栈跟踪结束 ---
服务器堆栈跟踪:
在 System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) 在 System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan 超时) 在 System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 方法调用,ProxyOperationRuntime 操作) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)
【问题讨论】:
-
看起来像 IO 异常,可能需要添加线程。看到我们的服务正在尝试做的代码会很痛苦。
-
在两边开启WCF追踪,也可以使用Wireshark之类的工具来抓取网络数据包。然后查看连接 (SSL/TLS) 是如何关闭的。许多因素都可能导致这种情况,例如代理问题或简单的电汇问题。
-
@LexLi 奇怪的是,如果达到 5 分钟标记,请求总是会失败。服务器或服务 web.config 上可能的超时设置是什么
标签: c# wcf iis wcf-binding wcf-security