Originally:
Scenario:
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:
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;
}
}
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:
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.
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:
Creating high performance WCF services
How to throttle a Wcf service, help prevent DoS attacks, and maintain Wcf scalability
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.
Had this problem with a long intialisation process that was being called from the OnStart event of a Windows Service Host installer. Fixed by setting the security mode and timeouts for the TCP binding.
// Create a channel factory.
NetTcpBinding b = new NetTcpBinding();
b.Security.Mode = SecurityMode.Transport;
b.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
b.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
b.MaxReceivedMessageSize = 1000000;
b.OpenTimeout = TimeSpan.FromMinutes(2);
b.SendTimeout = TimeSpan.FromMinutes(2);
b.ReceiveTimeout = TimeSpan.FromMinutes(10);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With