[en] Unable to receive events when connecting to more than one Zyan host (solved)

Topics: Technical Support
Jul 17, 2015 at 10:52 AM
Edited Jul 17, 2015 at 10:52 AM
[EN] Unable to receive events when connecting to more than one Zyan host.

Scenario: I have a client app that connects to several zyan hosts using TcpDuplexClientProtocolSetup. Each host has interfaces with events.

When I connect to the first host, events work fine. When I establish connection to a second host, I don't receive events from it. But the first connection still receives the events. If I change connection order, events always will work on the first connection, but not on the second.

What I have noticed: to setup my connections I use TcpDuplexClientProtocolSetup. Separate instance for each ZyanConnection. But if I'm using ONE protocol setup instance for both connections - second connection starts to receive events normally.

On second host we can see exception:

2015-07-16 16:17:23.7643 | Optum.Cm.Api.ZyanHost.ZyanHost -(30) [TRACE]: Canceled! Component type: Optum.Cm.Api.Provider.ZyanOperatorApi Id:8d317a07-25fd-4e12-b3ae-f77e03266101 Name:AuthClosed Host:api
EXCEPTION:
System.Net.Sockets.SocketException
No such host is known
Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)

Server stack trace:
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Manager.GetHostByName(String name) in D:\Externals\Zyan\source\Zyan.Communication\Protocols\Tcp\DuplexChannel\Manager.cs:line 161
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Connection..ctor(String address, TcpExChannel channel, Boolean keepAlive, UInt64 keepAliveTime, UInt64 KeepAliveInterval, Int16 maxRetries, Int32 retryDelay) in D:\Externals\Zyan\source\Zyan.Communication\Protocols\Tcp\DuplexChannel\Connection.cs:line 218
at Zyan.Communication.Protocols.Tcp.DuplexChannel.Connection.GetConnection(String address, TcpExChannel channel, Boolean keepAlive, UInt64 keepAliveTime, UInt64 KeepAliveInterval, Int16 maxRetries, Int32 retryDelay) in D:\Externals\Zyan\source\Zyan.Communication\Protocols\Tcp\DuplexChannel\Connection.cs:line 97
at Zyan.Communication.Protocols.Tcp.DuplexChannel.ClientTransportSink.PrepareRequest(IMessage msg, ITransportHeaders& requestHeaders) in D:\Externals\Zyan\source\Zyan.Communication\Protocols\Tcp\DuplexChannel\ClientTransportSink.cs:line 54
at Zyan.Communication.Protocols.Tcp.DuplexChannel.ClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream) in D:\Externals\Zyan\source\Zyan.Communication\Protocols\Tcp\DuplexChannel\ClientTransportSink.cs:line 93
at Zyan.Communication.ChannelSinks.Encryption.CryptoClientChannelSink.ObtainSharedKey(IMessage msg) in D:\Externals\Zyan\source\Zyan.Communication\ChannelSinks\Encryption\CryptoClientChannelSink.cs:line 108
at Zyan.Communication.ChannelSinks.Encryption.CryptoClientChannelSink.StartSecureTransaction(IMessage msg, ITransportHeaders requestHeaders) in D:\Externals\Zyan\source\Zyan.Communication\ChannelSinks\Encryption\CryptoClientChannelSink.cs:line 84
at Zyan.Communication.ChannelSinks.Encryption.CryptoClientChannelSink.ProcessEncryptedMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream) in D:\Externals\Zyan\source\Zyan.Communication\ChannelSinks\Encryption\CryptoClientChannelSink.cs:line 216
at Zyan.Communication.ChannelSinks.Encryption.CryptoClientChannelSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream) in D:\Externals\Zyan\source\Zyan.Communication\ChannelSinks\Encryption\CryptoClientChannelSink.cs:line 258
at Zyan.Communication.ChannelSinks.Compression.CompressionClientChannelSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream) in D:\Externals\Zyan\source\Zyan.Communication\ChannelSinks\Compression\CompressionClientChannelSink.cs:line 175
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

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 Zyan.Communication.Delegates.DelegateInterceptor.InvokeClientDelegate(Object[] args)
at Zyan.Communication.Delegates.DynamicEventWireBase.InvokeClientDelegate(Object[] args) in D:\Externals\Zyan\source\Zyan.Communication\Delegates\DynamicEventWireBase.cs:line 45


Example:
  1. Start first host
  2. Start second host
  3. Start client
http://www.filedropper.com/zyantestapplication
Coordinator
Jul 17, 2015 at 11:35 PM
Edited Jul 17, 2015 at 11:45 PM
Hi,

thanks for the sample project!
Looks like this issue: https://zyan.codeplex.com/workitem/2283

I haven't investigated this problem yet, but I suspect that it's the limitation of .NET Remoting.
It doesn't distinguish between copies of the same registered channel.

For example, when you register several instances of TcpEx channels, the first one will be chosen to handle all the communication. I think this is what happens when you create two TcpDuplexClientProtocolSetup classes (each one registers its own channel). Registering multiple different channels (HTTP+TCP+IPC) is perfectly fine, problems may only occur with multiple protocols of the same type (TCP+TCP).

I will look into it, but I'm not sure that it can be fixed if my guess about Remoting is right.
 
But if I'm using ONE protocol setup instance for both connections - second connection starts to receive events normally.
 
It is OK for you to use single protocol setup instance for both connection?
Can you use it as a workaround?

Regards, Alex
Coordinator
Nov 19 at 9:38 PM
Hello!

This issue has been finally resolved.
It was a limitation of the TcpExChannel, not the .NET Remoting itself.

Please download the latest version of the source code to get the fix.
The fix will be included in the upcoming Zyan 2.8 release.

Thanks for your patience!

Kind regards, Alex.
Marked as answer by yallie on 11/19/2016 at 1:42 PM