代码之家  ›  专栏  ›  技术社区  ›  Velocedge

一台服务器上出现WCF错误,但另一台服务器上没有:套接字连接已中止

  •  0
  • Velocedge  · 技术社区  · 6 年前

    CalculatorServiceReference.AnswerResultClient client = new CalculatorServiceReference.AnswerResultClient("NetTcpBinding_IAnswerResult");
    rtn = client.ServiceUpdate(org_int, sData); // ERROR HERE
    client.Close();
    

    在服务器中:

    public interface IAnswerResult
    {
        [OperationContract]
        bool ServiceUpdate(string org_int, string delimitedString);
    }
    public bool ServiceUpdate(string org_int, string delimitedString)
    {
    ...
    }
    

    我有一个相同的服务器和服务,工作正常,我似乎找不到任何区别。错误会立即发生,因此看起来不是超时问题。

    9/3/2018 7:52:44 AM:ERROR: System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully
    EternaService: 151 org192.168.100.2:6256151
    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:14:59.9969998'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
       at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
       at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
       --- End of inner exception stack trace ---
    
    Server stack trace: 
       at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
       at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
       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 CADEFileManager.CalculatorServiceReference.IAnswerResult.ServiceUpdate(String org_int, String delimitedString)
       at CADEFileManager.CalculatorServiceReference.AnswerResultClient.ServiceUpdate(String org_int, String delimitedString) in D:\Data\CADE.Net\FileManager\FileManager\Service References\CalculatorServiceReference\Reference.cs:line 67
       at CADEFileManager.FileManager.SendWCF(String org_int, String sData) in D:\Data\CADE.Net\FileManager\FileManager\FileManager.ashx.cs:line 9002
    

    System.ServiceModel.Channels.SocketConnection.ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException, TransferOperation transferOperation, Boolean aborted, String timeoutErrorString, TransferOperation timeoutErrorTransferOperation, SocketConnection socketConnection, TimeSpan remainingTime)
    System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
    System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
    System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
    System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
    System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
    System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
    System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
    System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
    System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
    System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
    System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
    System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
    System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
    System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
    System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
    System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
    CADEFileManager.CalculatorServiceReference.IAnswerResult.ServiceUpdate(String org_int, String delimitedString)
    CADEFileManager.CalculatorServiceReference.AnswerResultClient.ServiceUpdate(String org_int, String delimitedString)
    CADEFileManager.FileManager.SendWCF(HttpContext context, String org_int, String sData)
    CADEFileManager.FileManager.ProcessRequest(HttpContext context)
    
    3 回复  |  直到 6 年前
        1
  •  0
  •   gulshan arora    6 年前

    尝试为绑定配置“receiveTimeout”属性。

    <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="someBinding" receiveTimeout ="00:10:00">
              ...       
            </binding>
        </bindings>
      </system.serviceModel>
    

    另请参阅绑定类的“closeTimeout”、“sendTimeout”和“openTimeout”属性。

        2
  •  0
  •   Andrei Petrut    6 年前

    您可以尝试在命令行界面中键入“netstat”以查看正在使用的端口。

        3
  •  0
  •   Velocedge    6 年前

    我在一篇评论的基础上找到了解决办法 https://support.microsoft.com/en-us/help/896861/you-receive-error-401-1-when-you-browse-a-web-site-that-uses-integrate .

    所以,我所做的只是将WCF链接从localhost改为计算机名,它就成功了!!