一台服务器上的WCF错误,而不是另一台服务器上的错误:套接字连接中止

问题描述 投票:0回答:3

当我调用WCF服务引用(net.tcp:// localhost:6256 / CalculatorService / mex)时,我收到此错误:

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)
c# .net sockets wcf
3个回答
0
投票

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

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

另请参阅Binding类的“closeTimeout”,“sendTimeout”和“openTimeout”属性。


0
投票

您是否检查过该机器上的端口是否已打开?或者它可能被另一个进程使用?

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


0
投票

我找到了基于https://support.microsoft.com/en-us/help/896861/you-receive-error-401-1-when-you-browse-a-web-site-that-uses-integrate评论的解决方案。

Windows Service Pack更新包括环回检查安全功能,旨在帮助防止对计算机的反射攻击。因此,如果您使用的FQDN或自定义主机标头与本地计算机名称不匹配,则身份验证将失败。

所以,我所做的只是将WCF链接从localhost更改为计算机的名称,它工作了!!

© www.soinside.com 2019 - 2024. All rights reserved.