c# - WCF错误: The socket connection was aborted

标签 c# sockets wcf net-tcp

我使用topshelf托管WCF连接,服务配置使用行为和tcp连接,如下所示:

<behaviors>
  <serviceBehaviors>
    <behavior name="MetaDataBehvior">
      <serviceMetadata />
    </behavior>
    <behavior>
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <netTcpBinding>
    <binding name="NetTcpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="Transport">
        <!--Transport security is enabled Because all machinses on the same Domain (intranet) -->
        <!-- http://www.karthikscorner.com/sharepoint/wcf-transport-security/ -->
        <!--Transport security is enabled-->
          <transport clientCredentialType="Windows"
                    protectionLevel="EncryptAndSign" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>

我什至尝试使用节流,但在多次使用该服务后却没有任何变化,但出现了错误:

发生一个或多个错误。

System.AggregateException: One or more errors occurred. ---> 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.9844041'. ---> System.IO.IOException: The write operation failed, see inner exception. ---> 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.9844041'.



有关如何跟踪或解决此问题的任何建议

最佳答案

WCF包含一些类,可用于跟踪/调试应用程序

首先是启用跟踪日志记录/消息日志记录,您可以使用SvcConfigEditor使您的生活更简单
enter image description here

然后只需进入“EndToEnd跟踪”部分并编辑配置以适合您的需求,

将跟踪与消息传递结合使用,将为您提供一种将messageID(GUID)与生成的跟踪相关联的方法,并且在某些情况下,可以找到给您带来问题的消息。

您可以检查的另一件事是在ServiceBehavior设置中启用ServiceAudit标记,这将使您可以检查由服务引起的安全事件。

enter image description here

关于c# - WCF错误: The socket connection was aborted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53603405/

相关文章:

c# - 使用c#将csv文件插入MYSQL表

java - 检测连接到我的网络的设备

java - 套接字连接无法通过可执行 jar 工作

c# - 使用 PrincipalContext.ValidateCredentials 对本地计算机进行身份验证时出错?

c# - IIS 托管 WCF 服务 : Integration tests and code coverage

c# - 后台任务和持续时间(Windows Phone 7)

c# - 使用 msmq 进行异步日志记录

WCF、 Entity Framework 和数据契约

c# - 在 C# 中使用 Moq 引发复杂事件

java - java中如何接收广播消息