[en] An exception from ZyanComponentHost (solved)

Topics: Technical Support
Sep 27, 2014 at 3:23 AM
Edited Sep 27, 2014 at 3:53 AM
My code:
        using (ZyanComponentHost host = new ZyanComponentHost("Server", new TcpDuplexServerProtocolSetup(m_port, new ClientAuthProvider(), true)))
            {
                host.PollingEventTracingEnabled = true;
                host.RegisterComponent<IServer, Server>(ActivationType.Singleton);
                host.SessionManager.SessionAgeLimit = 10;
                host.SessionManager.SessionSweepInterval = 1;

                host.ClientLoggedOff += new EventHandler<LoginEventArgs>((sender, e) =>
                {
                    //...
                });

                host.ClientSessionTerminated += new EventHandler<LoginEventArgs>((sender, e) =>
                {
                    //...
                });

                host.SubscriptionCanceled += host_SubscriptionCanceled;

                host.InvokeCanceled += host_InvokeCanceled;

                host.InvokeRejected += host_InvokeRejected;

                host.EnableDiscovery();

                REMOTING_SERVER = (Server)host.ComponentCatalog.GetComponent<IServer>();
               
                Application.Run(new MainForm());
            }
        }
Without the operation of the software. Occasional exception。

Exception's Stack:
at System.Net.Sockets.Socket.EndAccept(Byte[] ByRef, Int32 ByRef, System.IAsyncResult)
at System.Net.Sockets.Socket.EndAccept(System.IAsyncResult)
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Manager.listener_Accept(System.IAsyncResult)
at System.Net.LazyAsyncResult.Complete(IntPtr)
at System.Net.ContextAwareResult.CompleteCallback(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Net.ContextAwareResult.Complete(IntPtr)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2014-09-27T01:50:52.000000000Z" />
<EventRecordID>69076</EventRecordID>
<Channel>Application</Channel>
<Computer>WDXCNS7AY6KPQIC</Computer>
<Security />
</System>
<EventData>
<Data>Application: Server.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.Sockets.SocketException
Stack:
at System.Net.Sockets.Socket.EndAccept(Byte[] ByRef, Int32 ByRef, System.IAsyncResult)
at System.Net.Sockets.Socket.EndAccept(System.IAsyncResult)
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Manager.listener_Accept(System.IAsyncResult)
at System.Net.LazyAsyncResult.Complete(IntPtr)
at System.Net.ContextAwareResult.CompleteCallback(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Net.ContextAwareResult.Complete(IntPtr)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
</Data>
</EventData>
</Event>
Coordinator
Sep 27, 2014 at 6:31 PM
Hi,

please post the exception message and error code (SocketException should have internal error code).
Have you tried running your code on another computer?
What steps do I need to reproduce the exception?

Regards, Alex.
Oct 11, 2014 at 8:40 AM
Another CurrentDomain_UnhandledException Eorr: "object graph cannot be null". it occurred when the application starts.
Stack:
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Connection.SendChannelInfo()
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Connection..ctor(Socket socket, TcpExChannel channel, Boolean keepAlive, UInt64 keepAliveTime, UInt64 KeepAliveInterval, Int16 maxRetries, Int32 retryDelay)
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Connection.CreateConnection(Socket socket, TcpExChannel channel, Boolean keepAlive, UInt64 keepAliveTime, UInt64 KeepAliveInterval, Int16 maxRetries, Int32 retryDelay)
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Manager.listener_Accept(IAsyncResult ar)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.CompleteCallback(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Sockets.Socket.AcceptCallback(Object nullState)
at System.Net.Sockets.Socket.RegisteredWaitCallback(Object state, Boolean timedOut)
at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)
Coordinator
Oct 13, 2014 at 3:28 PM
Hi,

what version of Zyan are you using?
Please check if the error reproduces on the latest version built from SVN repository sources.
Oct 16, 2014 at 4:30 PM
The dll's version my using is 2.5.
I'll try the SVN source later.
thanks
Oct 17, 2014 at 6:27 AM
Edited Oct 17, 2014 at 6:29 AM
the problem still exist in SVN source code,
reason: channel.ChannelData is null.
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Connection.SendChannelInfo()
Coordinator
Oct 17, 2014 at 11:58 AM
Edited Oct 17, 2014 at 12:30 PM
Hi,

I managed to reproduce the problem on a synthetic application (I had to add
significant delay to TcpEx's Manager.StartListening method in Zyan itself).

The problem can be classified as a race condition in an extremely unlikely situation.
I can hardly imagine how could this problem ever occur in a real application.
Anyway, I'm filing this issue and I'm going to provide the fix today.

In the meantime, could you please demonstrate your code?
Please send me a zipped project of an application that runs into this exception on startup.
I'm very curious about how this could happen on a plain unmodified version of Zyan.

Regards, Alexey
Coordinator
Oct 17, 2014 at 12:02 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Oct 17, 2014 at 1:16 PM
The issue has been fixed!
Please download the latest source from SVN.

Regards, Alexey
Oct 17, 2014 at 2:45 PM
Edited Oct 17, 2014 at 2:59 PM
Thank you very much for your kind, I will try soon.
I can't provide my program because it depends on the some hardware.

and,
The case just as you say,
In my project, client program start firstly and try connect to server,
then server start slowly.

so, I think you are right, yallie.

thanks again.

best wishes.