zoukankan      html  css  js  c++  java
  • WCF:调用超时

    今天调用查询方法的时候,出了一个本地socket超时的错误,而这个查询方法昨天还是正常调用的。

    调试了一会,发现只要有返回值,就会报错,如果无返回值就是正常的。估计是序列化的时候有问题,以为是没给类加上[Serializable],后来加了也不行。

    经过逐步排查,发现是返回的类加了一个枚举类型的属性,但没有给这个枚举属性赋值导致的。

    错误内容
    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.9960000'.

    内部错误1:
    {"The read operation failed, see inner exception."}

    内部错误2:
    {"远程主机强迫关闭了一个现有的连接。"}

    错误原因

    返回的类中有一个枚举属性,但没赋值。

    解决

    给这个属性赋一个默认值就可以了。

    今天居然又出这个错误了。结果问题发生的原因却是因为我配置了Security:

    NetTcpBinding binding = new NetTcpBinding();
    binding.Security.Mode = SecurityMode.None;
    binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

    把Security这两项删除就没错了。

    WCF的错误信息真奇怪。

  • 相关阅读:
    C# Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
    C# Collection was modified;enumeration operation may not execute
    C# 写文件
    AJAX 入门教程
    ABP 软删除ISoftDelete
    C# 随机列表
    C# ConfigurationManager 类的使用
    mui 关闭当前窗口
    C# 委托
    VSTO:使用C#开发Excel、Word【13】
  • 原文地址:https://www.cnblogs.com/ego/p/2405705.html
Copyright © 2011-2022 走看看