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

查看:284
本文介绍了套接字连接中止 - 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天全站免登陆