[SocketException (0x2746): 远程主机强迫关闭了一个现有的连接。]
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6556175
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +130
[IOException: 无法从传输连接中读取数据: 远程主机强迫关闭了一个现有的连接。。]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +296
System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +19
System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +251
[WebException: 基础连接已经关闭: 接收时发生错误。]
System.Net.HttpWebRequest.GetResponse() +6557544
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +55
[CommunicationException: 接收对 http://10.10.101.242:8095/ClientService.svc 的 HTTP 响应时发生错误。
这可能是由于服务终结点绑定未使用 HTTP 协议造成的。
这还可能是由于服务器中止了 HTTP 请求上下文(可能由于服务关闭)所致。有关详细信息,请参见服务器日志。]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10990855
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336
CCtrmPro.ClientManageService.IClientManagementService.GetClientList(String str) +0
CCtrmPro.ClientManageService.ClientManagementServiceClient.GetClientList(String str) in g:\Service References\ClientService\Reference.cs:155
CCtrmPro.ClientManagement.ClientInformation.InitClientList() in g:\Client\ClientInformation.aspx.cs:37
CCtrmPro.ClientManagement.ClientInformation.Page_Load(Object sender, EventArgs e) in g:\CCtrmPro\Client\ClientInformation.aspx.cs:19
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772+
解决方案:
1. WCF中接口方法传递的DataTable替换成Dataset
2.认为WCF来传递DataTable的Bug,没有设置tableName造成
3.认为传输数据量大,造成服务器端的服务关闭,解决方案详情。
可根据路径查看服务器的日志记录:C:\Windows\System32\LogFiles\HTTPERR
部分日志如下,可根据自己访问的端口查看。
#Software: Microsoft HTTP API 2.0
#Version: 1.0
#Date: 2017-02-10 00:50:54
#Fields: date time c-ip c-port s-ip s-port cs-version cs-method cs-uri sc-status s-siteid s-reason s-queuename
2017-02-10 00:50:54 10.10.101.242 1700 10.10.101.242 80 - - - - - Timer_ConnectionIdle -
2017-02-10 00:51:09 10.10.101.242 59305 10.10.101.242 8099 - - - - - Timer_ConnectionIdle -
2017-02-10 00:51:09 10.10.101.242 58311 10.10.101.242 8099 - - - - - Timer_ConnectionIdle -
2017-02-10 00:51:09 10.10.101.242 59306 10.10.101.242 8099 - - - - - Timer_ConnectionIdle -
2017-02-10 00:51:29 10.10.101.242 58313 10.10.101.242 8085 - - - - - Timer_ConnectionIdle -
2017-02-10 01:28:12 10.10.101.242 60406 10.10.101.242 8095 HTTP/1.1 POST /ClientService.svc - 4 Request_Cancelled ASP.NET+v4.0
2017-02-10 01:30:24 ::1%0 60402 ::1%0 27076 - - - - - Timer_ConnectionIdle -
2017-02-10 01:30:29 10.10.101.242 60408 10.10.101.242 8095 - - - - - Timer_ConnectionIdle -
2017-02-10 01:34:11 10.10.101.242 60505 10.10.101.242 8095 HTTP/1.1 POST /ClientService.svc - 4 Request_Cancelled ASP.NET+v4.0
2017-02-10 01:35:19 10.10.101.242 60491 10.10.101.242 8085 - - - - - Timer_ConnectionIdle -
2017-02-10 01:35:59 10.10.101.242 60494 10.10.101.242 8095 - - - - - Timer_ConnectionIdle -
2017-02-10 01:36:24 ::1%0 60501 ::1%0 27076 - - - - - Timer_ConnectionIdle -
2017-02-10 01:41:19 10.10.101.242 60524 10.10.101.242 8095 - - - - - Timer_ConnectionIdle -
2017-02-10 01:41:54 ::1%0 60530 ::1%0 27076 - - - - - Timer_ConnectionIdle -
2017-02-10 01:45:04 ::1%0 60560 ::1%0 27076 - - - - - Timer_ConnectionIdle -
2017-02-10 01:45:04 ::1%0 60562 ::1%0 27076 - - - - - Timer_ConnectionIdle -
2017-02-10 01:45:04 ::1%0 60553 ::1%0 27076 - - - - - Timer_ConnectionIdle -
2017-02-10 01:46:04 ::1%0 60567 ::1%0 58348 - - - - - Timer_ConnectionIdle -
2017-02-10 01:46:04 ::1%0 60563 ::1%0 27076 - - - - - Timer_ConnectionIdle -
2017-02-10 01:51:04 ::1%0 60706 ::1%0 58348 - - - - - Timer_ConnectionIdle -
...........................................
经过验证,解决方案 :
1.经过本人亲自验证,确实有效。
2.给DataTable添加了tableName还是无效,问题依然解决不了。
3.服务器日志反应访问端口失败,但是本人看不出是哪里的问题,大家自行查看。
前提是服务部署正确,客户端调用的代码逻辑也不要出错,这样有利于缩小范围。
另外msdn中文论坛WCF板块有相关提问,已经解决,点击可查看。