में ऑप्टिमाइज़ेशन मैं प्रकाशक ग्राहक पैटर्न के आधार पर एक सिस्टम पर काम कर रहा हूं। मेरे पास एक डब्ल्यूसीएफ सेवा है जो एक डब्ल्यूपीएफ आवेदन में चल रही है। ऐसे कई ग्राहक हैं जो सेवा से जुड़ते हैं। ग्राहक पक्ष भी WPF है। मैं नीचे अपने सिस्टम के कोड के टुकड़े संलग्न कर रहा हूँ:संचार ओब्जेक्टएबॉर्टेड एक्सेप्शन एंड कम्युनिकेशनऑब्जेक्टफॉल्टेड डब्ल्यूसीएफ सेवा
सेवा:
[ServiceContract(Namespace = "http://AutoFXProfitsServer", SessionMode = SessionMode.Required, CallbackContract = typeof(ITradeMirrorClientContract))]
public interface ITradeMirror
{
[OperationContract]
string Subscribe(string userName, string password, int accountID);
[OperationContract]
bool Unsubscribe(string userName, string password, int accountID);
[OperationContract]
void PublishNewSignal(string signalInformation);
}
public interface ITradeMirrorClientContract
{
[OperationContract(IsOneWay = true)]
void NewSignal(string signalInformation);
}
public class NewSignalEventArgs : EventArgs
{
public string SignalInformation;
}
.
.
.
.
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, AutomaticSessionShutdown = false)]
public class TradeMirrorService : DependencyObject, ITradeMirror
{
.
.
.
.
public string Subscribe(string userName, string password, int accountID)
{
try
{
if (AuthenticationSuccessful)
{
_callback = OperationContext.Current.GetCallbackChannel<ITradeMirrorClientContract>();
_newSignalHandler = new NewSignalEventHandler(NewSignalHandler);
NewSignalEvent -= _newSignalHandler;
NewSignalEvent += _newSignalHandler;
string suffixes = GetSuffixes();
return suffixes;
}
else
{
return "FAILED";
}
}
catch (Exception exception)
{
return "FAILED";
}
}
public bool Unsubscribe(string userName, string password, int accountID)
{
try
{
if (SearchHelper.UnAuthenticateUserCredentials(userName, password, accountID, _helper))
{
_callback = OperationContext.Current.GetCallbackChannel<ITradeMirrorClientContract>();
_newSignalHandler = new NewSignalEventHandler(NewSignalHandler);
NewSignalEvent -= _newSignalHandler;
return true;
}
else
{
return false;
}
}
catch (Exception exception)
{
return false;
}
}
public void PublishNewSignal(string signalInformation)
{
try
{
if (HeartBeatMessage())
{
}
else
{
_systemOrderID++;
signalInformation = TransformSignalInformation(signalInformation, _systemOrderID);
}
var e = new NewSignalEventArgs {SignalInformation = signalInformation};
NewSignalEvent(this, e);
}
catch (Exception exception)
{
}
}
और मेरे app.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding closeTimeout="23:59:59" openTimeout="23:59:59" receiveTimeout="23:59:59" sendTimeout="23:59:59" transactionFlow="false" transferMode="Buffered"
transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="524288" maxBufferSize="65536"
maxConnections="1000" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="23:59:59" enabled="false"/>
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" httpGetUrl="http://95.138.188.232/autofxprofits/service"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup> </configuration>
प्रणाली किसी भी मुद्दे के बिना लंबी अवधि के लिए पूरी तरह से काम करता है ।
CommunicationObjectAbortedException या CommunicationObjectFaultedException
System.ServiceModel.CommunicationObjectAbortedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted.
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at AutoFXProfitsServer.ITradeMirrorClientContract.NewSignal(String signalInformation)
at AutoFXProfitsServer.TradeMirrorService.NewSignalHandler(Object sender, NewSignalEventArgs e) in D:\Work\Trade Mirror - Kumar\AutoFXToolsTradeMirror\AutoFXProfitsServer\Service.cs:line 232
at AutoFXProfitsServer.TradeMirrorService.PublishNewSignal(String signalInformation) in D:\Work\Trade Mirror - Kumar\AutoFXToolsTradeMirror\AutoFXProfitsServer\Service.cs:line 171
या,
System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at AutoFXProfitsServer.ITradeMirrorClientContract.NewSignal(String signalInformation)
at AutoFXProfitsServer.TradeMirrorService.NewSignalHandler(Object sender, NewSignalEventArgs e) in D:\Work\Trade Mirror - Kumar\AutoFXToolsTradeMirror\AutoFXProfitsServer\Service.cs:line 235
at AutoFXProfitsServer.TradeMirrorService.NewSignalEventHandler.Invoke(Object sender, NewSignalEventArgs e)
at AutoFXProfitsServer.TradeMirrorService.PublishNewSignal(String signalInformation) in D:\Work\Trade Mirror - Kumar\AutoFXToolsTradeMirror\AutoFXProfitsServer\Service.cs:line 174
बस: क्या होता है कि किसी कारण (जिसके बारे में मुझे यकीन है कि entirley नहीं कर रहा हूँ) के लिए सेवा कभी कभी अपवाद के साथ दुर्घटनाग्रस्त हो गया है दोहराने के लिए, ये अपवाद PublishNewSignal विधि में होता है। एक कारण है कि मैंने सभी परीक्षणों से बाहर किया है यह है कि ऐसा तब होता है जब कोई ग्राहक असामान्य रूप से बंद हो जाता है। उदाहरण के लिए, क्लाइंट प्रक्रिया टास्क मैनेजर आदि से बंद है
लेकिन यह समस्या एक बड़ा दर्द है और हम इस स्थिरता मुद्दे को ठीक किए बिना फॉरवर्ड नहीं ले सकते हैं। क्या किसी को कोई विचार है कि संचार वस्तु क्यों गलती हो जाती है और सेवा दुर्घटनाग्रस्त हो जाती है?
इस पर कुछ सकारात्मक प्रतिक्रिया प्राप्त करने की उम्मीद है।
धन्यवाद। उमर
अधिकांशतः एक टाइमआउट या क्षणिक नेटवर्क समस्या। मैं एक [डब्ल्यूसीएफ ट्रेस] (http://msdn.microsoft.com/en-us/library/ms733025.aspx) चलाता हूं यह देखने के लिए कि क्या होता है इसके बारे में अधिक विस्तृत जानकारी है या नहीं। –