套接字连接已中止 - CommunicationException [英] The socket connection was aborted - CommunicationException

查看:35
本文介绍了套接字连接已中止 - CommunicationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原本:

  • 我以为这是一个循环引用问题........结果不是.
  • 问题是因为根本没有配置服务配置.
  • 由于默认值非常低,发送大量数据会使服务崩溃.

场景:

  • 似乎我的 WCF 服务中可能有循环引用,但使用[DataContract(IsReference=true)]"并不能帮助修复它.
  • 我收到错误消息套接字连接已中止.这可能是由于处理您的消息时出错或远程主机超出接收超时,或基础网络资源问题.本地套接字超时为 '00:01:00'."
  • 我错过了什么吗?

代码:

[DataContract(IsReference=true)]
public class Message
{
    [DataMember]
    public string TopicName { get; set; }

    [DataMember]
    public string EventData { get; set; }

    [DataMember]
    public SerializableDictionary<string, FuturesLineAsset> FuturesLineDictionary { get; set ; }
}

想法:

  • 我想知道是不是因为我有一个 FuturesAsset 类,它有一个 BindableDictionary 类型的属性(这是一个自定义对象),并且该属性包含一个 FuturesLinesAssets 列表.
  • 见下文:

家长:

public class FuturesAsset
{
    public string AssetName { get; set; }
    public BindableDictionary<string, FuturesLineAsset> AssetLines { get; private set; }

    public FuturesAsset()
    {
        AssetLines = new BindableDictionary<string, FuturesLineAsset>();
    }

    public FuturesAsset(string assetName)
    {
        AssetLines = new BindableDictionary<string, FuturesLineAsset>();
        AssetName = assetName;
    }
}

孩子:

public class FuturesLineAsset
{

    public string ReferenceAsset { get; set; }
    public string MID { get; set; }
    public double LivePrice { get; set; }
    public DateTime UpdateTime { get; set; }
    public DateTime LastContributedTime { get; set; }
    public double Spread { get; set; }
    public double Correlation { get; set; }
    public DateTime Maturity { get; set; }
    public double ReferenceCurve { get; set; }

    public FuturesLineAsset(string mID, string referenceAsset, double livePrice)
    {
        MID = mID;
        ReferenceAsset = referenceAsset;
        ReutersLivePrice = livePrice;
    }
}

推荐答案

该异常与循环引用无关,它只是在您尝试通过网络传输大量数据时超时.

that exception is not related to Circular Reference, it's just purely timing out as you try to pump tons of data over the wire.

WCF 附带的默认值非常低(我相信这些已在 WCF 4 中更改).阅读这两篇博文,它们应该能让您了解如何限制您的服务:

The default values that comes with WCF are very very low (these have been changed in WCF 4 I believe). Have a read on these two blog posts, they should give you an idea on how to dethrottle your service:

创建高性能 WCF服务

如何限制 Wcf 服务、帮助防止 DoS 攻击并保持 Wcf 可扩展性

更新:此外,WCF 配置中有许多不同的超时时间,并且取决于您正在谈论的是客户端还是服务器,您需要更新不同的超时子句......有阅读此线程 关于每一个的含义,你应该能够弄清楚你需要提升哪个.或者,如果您真的不关心调用是否需要很长时间才能完成,您可以将每个超时设置为 int.max.

Update: also, there are a number of different timeouts in the WCF configuration and depending whether it's the client or server you're talking about you need to update a different timeout clause... have a read of this thread on what each one means and you should be able to figure out which one you need to bump up. Or, you could just set every timeout to int.max if you don't really care if a call can take a loong time to complete.

这篇关于套接字连接已中止 - CommunicationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆