Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

c# - The socket connection was aborted - CommunicationException

Originally:

  • I thought this was a circular reference problem........turns out it's not.
  • The problem arose from having not configured the service configurations at all.
  • Since the defaults are very low, sending lots of data will make the service collapse.

Scenario:

  • It seems I may have circular references in my WCF service, but using "[DataContract(IsReference=true)]", does nothing to help fix it.
  • I receive the error "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:01:00'."
  • Have I missed something?

Code:

[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 ; }
}

Thoughts:

  • I wonder if it's because I have a class FuturesAsset, that has a property of type BindableDictionary (THIS IS A CUSTOM OBJECT), and that property holds a list of FuturesLinesAssets.
  • See below:

Parent:

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;
    }
}

Child:

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;
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This error can be caused by a number of things. While it was a timing issue in this case, it usually has nothing to do with timings, especially if the error is received immediately. Possible reasons are:

  • The objects used as parameters or return types in your contract don't have parameterless constructors and are not decorated with the DataContract attribute. Check the classes used as parameters or return types, but also all the types used by the public properties of those classes. If you implement a constructor with parameters for one of those classes, the compiler will not add the default parameterless constructor for you anymore, so you will need to add that yourself.
  • The default limits defined in service configuration are too low (MaxItemsInObjectGraph, MaxReceivedMessageSize, MaxBufferPoolSize, MaxBufferSize, MaxArrayLength).
  • Some public properties of your DataContract objects are read-only. Make sure all public properties have both getters and setters.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...