- This topic has 2 replies, 2 voices, and was last updated 9 years, 5 months ago by Anonymous.
-
AuthorPosts
-
July 9, 2015 at 19:26 #3961AnonymousInactive
Hello guys,
I am currently searching for a sockets solution that I could use in order to connect multiple SocketClients (all in same WInForms app) to as-many multiple SocketServers (each socket server is a different app on different computer).
I have downloaded the networkcomms.net2.3.1, followed the example in ExamplesChat.WPF and started to work on my own solution.
First of all, I like it very much that I can work simply with objects (serialized, etc).So, same app is either a clients-farm or a sockets server, depending on parameter.
If server, the app was configured to handle some packets that it will receive, if client instead, is configured to handle other packets.
The problems that I encounter is that I can’t make it work. Seems connections get closed just before completing the handshake. I will attach some logs:
2015-07-09 20:25:56.577 [Info] – Added incoming packetHandler for ‘ChatMessage’ packetType.
2015-07-09 20:25:56.577 [Info] – Added incoming packetHandler for ‘PingPong’ packetType.
2015-07-09 20:25:56.577 [Info] – Added globalConnectionShutdownDelegates. 1
2015-07-09 20:25:56.577 [Info] – Added globalConnectionEstablishDelegates. 1
2015-07-09 20:25:56.577 [Info] – Added incoming packetHandler for ‘QueryStats’ packetType.
2015-07-09 20:25:56.577 [Info] – Added incoming packetHandler for ‘QueryInitialAppData’ packetType.
2015-07-09 20:25:56.594 [Debug] – Enabling local server mode. Any existing connections will be closed.
2015-07-09 20:25:56.594 [Trace] – NetworkCommsDotNet shutdown initiated.
2015-07-09 20:25:56.594 [Trace] – Closing 0 connections.
2015-07-09 20:25:56.594 [Info] – NetworkCommsDotNet has shutdown
2015-07-09 20:25:56.594 [Info] – Added new TCP localEndPoint – 0.0.0.0:19999
2015-07-09 20:25:56.594 [Debug] – Listening for incoming TCP connections on:
2015-07-09 20:25:56.594 [Debug] – 0.0.0.0:19999
2015-07-09 20:25:56.594 [Debug] –2015-07-09 20:25:56.594 [Info] – TCP IncomingConnectionWorker thread started.
2015-07-09 20:25:59.811 [Debug] – will try to send a InitialAppDataResponse to any connected clients, if any
2015-07-09 20:26:21.695 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43706′ and connectionType=’TCP’
2015-07-09 20:26:21.695 [Trace] – Creating new TCPConnection to connectionInfo='[TCP] Local -> ###.###.###.##:43706′. Connection will be established.
2015-07-09 20:26:21.695 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43706′ and connectionType=’TCP’
2015-07-09 20:26:21.695 [Trace] – Adding connection reference by endPoint. Connection='[TCP] Local -> ###.###.###.##:43706′.
2015-07-09 20:26:21.695 [Trace] – RetrieveConnection by remoteEndPoint=’###.###.###.##:43706′ and connectionType=’TCP’. No matching connection was found.
2015-07-09 20:26:21.695 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43706′ and connectionType=’TCP’
2015-07-09 20:26:21.703 [Trace] – Establishing new connection with [TCP] Local -> ###.###.###.##:43706
2015-07-09 20:26:21.703 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43706′ and connectionType=’TCP’
2015-07-09 20:26:21.703 [Trace] – Listening for incoming data from [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706
2015-07-09 20:26:21.703 [Debug] – Closing connection with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706 due to error from [44].
2015-07-09 20:26:21.703 [Trace] – Entering RemoveConnectionReference for [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706
2015-07-09 20:26:21.703 [Trace] – … checking for completed packet with 132 bytes read.
2015-07-09 20:26:21.703 [Trace] – Removed connection reference by endPoint for [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706
2015-07-09 20:26:21.703 [Debug] – Triggered global shutdown delegates with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706
2015-07-09 20:26:21.703 [Debug] – Connection with ‘[TCP] ###.###.###.##:19999 -> ###.###.###.##:43706’ has been closed.
2015-07-09 20:26:21.774 [Debug] – Received packet of type ‘ConnectionSetup’ from [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706, containing 86 header bytes and 46 payload bytes.
2015-07-09 20:26:21.774 [Trace] – … handling packet type ‘ConnectionSetup’ inline. Loop index – 0
2015-07-09 20:26:21.774 [Trace] – Handling a ConnectionSetup packet from [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706 with a priority of AboveNormal.
2015-07-09 20:26:21.774 [Trace] – Removing 132 bytes from incoming packet buffer from connection with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706.
2015-07-09 20:26:21.774 [Debug] – Closing connection with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706 due to error from [13].
2015-07-09 20:26:21.774 [Trace] – Entering RemoveConnectionReference for [TCP] ###.###.###.##:19999 -> ###.###.###.##:43706
2015-07-09 20:26:21.795 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43709′ and connectionType=’TCP’
2015-07-09 20:26:21.795 [Trace] – Creating new TCPConnection to connectionInfo='[TCP] Local -> ###.###.###.##:43709′. Connection will be established.
2015-07-09 20:26:21.795 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43709′ and connectionType=’TCP’
2015-07-09 20:26:21.795 [Trace] – Adding connection reference by endPoint. Connection='[TCP] Local -> ###.###.###.##:43709′.
2015-07-09 20:26:21.795 [Trace] – RetrieveConnection by remoteEndPoint=’###.###.###.##:43709′ and connectionType=’TCP’. No matching connection was found.
2015-07-09 20:26:21.795 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43709′ and connectionType=’TCP’
2015-07-09 20:26:21.795 [Trace] – Establishing new connection with [TCP] Local -> ###.###.###.##:43709
2015-07-09 20:26:21.795 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:43709′ and connectionType=’TCP’
2015-07-09 20:26:21.795 [Trace] – Listening for incoming data from [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709
2015-07-09 20:26:21.795 [Trace] – … checking for completed packet with 132 bytes read.
2015-07-09 20:26:21.795 [Debug] – Closing connection with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709 due to error from [44].
2015-07-09 20:26:21.795 [Debug] – Received packet of type ‘ConnectionSetup’ from [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709, containing 86 header bytes and 46 payload bytes.
2015-07-09 20:26:21.795 [Trace] – … handling packet type ‘ConnectionSetup’ inline. Loop index – 0
2015-07-09 20:26:21.795 [Trace] – Entering RemoveConnectionReference for [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709
2015-07-09 20:26:21.796 [Trace] – Removed connection reference by endPoint for [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709
2015-07-09 20:26:21.796 [Debug] – Triggered global shutdown delegates with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709
2015-07-09 20:26:21.796 [Debug] – Connection with ‘[TCP] ###.###.###.##:19999 -> ###.###.###.##:43709’ has been closed.
2015-07-09 20:26:21.795 [Trace] – Handling a ConnectionSetup packet from [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709 with a priority of AboveNormal.
2015-07-09 20:26:21.796 [Trace] – Removing 132 bytes from incoming packet buffer from connection with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709.
2015-07-09 20:26:21.796 [Debug] – Closing connection with [TCP] ###.###.###.##:19999 -> ###.###.###.##:43709 due to error from [13].On the other hand, in the other app that “spawns” some background threads in order to find out which “server” is alive and connect and then communicate to it, here is how the logs look like:
2015-07-09 20:26:21.736 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.736 [Trace] – Creating new TCPConnection to connectionInfo='[TCP] ###.###.###.##:43706 -> ###.###.###.##:19999′. Connection will be established.
2015-07-09 20:26:21.736 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.736 [Trace] – Adding connection reference by endPoint. Connection='[TCP] ###.###.###.##:43706 -> ###.###.###.##:19999′.
2015-07-09 20:26:21.736 [Trace] – RetrieveConnection by remoteEndPoint=’###.###.###.##:19999′ and connectionType=’TCP’. No matching connection was found.
2015-07-09 20:26:21.736 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.736 [Trace] – Establishing new connection with [TCP] ###.###.###.##:43706 -> ###.###.###.##:19999
2015-07-09 20:26:21.736 [Trace] – Connecting TCP client with [TCP] ###.###.###.##:43706 -> ###.###.###.##:19999
2015-07-09 20:26:21.736 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.736 [Trace] – Listening for incoming data from [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.736 [Debug] – Sending connnectionInfo to [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.736 [Trace] – … creating comms packet. PacketObject data size is 46 bytes
2015-07-09 20:26:21.736 [Trace] – Entering packet send of ‘ConnectionSetup’ packetType to [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999. PacketCheckSum=8414B5C9BD12DE1E13303A7541A6D780
2015-07-09 20:26:21.736 [Debug] – Sending a packet of type ‘ConnectionSetup’ to [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999 containing 86 header bytes and 46 payload bytes. Allowing 1000.0 ms/KB for send.
2015-07-09 20:26:21.736 [Trace] – … 0.129KB written to TCP netstream at average of InfinityKB/s. Current:0.00 ms/KB, AVG:0.00 ms/KB.
2015-07-09 20:26:21.736 [Trace] – Completed packet send of ‘ConnectionSetup’ packetType to [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.795 [Debug] – Closing connection with [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999 from [-2].
2015-07-09 20:26:21.803 [Trace] – Entering RemoveConnectionReference for [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.803 [Trace] – Removed connection reference by endPoint for [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.803 [Debug] – Closing connection with [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999 due to error from [44].
2015-07-09 20:26:21.820 [Trace] – Entering RemoveConnectionReference for [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.829 [Error] – Caught ConnectionSetupException while trying to establish a connection with ###.###.###.##
Connection was closed during establish handshake.
2015-07-09 20:26:21.829 [Debug] – CLIENT_APP – Sending a PING request to ###.###.###.## at 09/07/2015 8:26:21 PM
2015-07-09 20:26:21.829 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.829 [Trace] – Creating new TCPConnection to connectionInfo='[TCP] ###.###.###.##:43709 -> ###.###.###.##:19999′. Connection will be established.
2015-07-09 20:26:21.829 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.829 [Trace] – Adding connection reference by endPoint. Connection='[TCP] ###.###.###.##:43709 -> ###.###.###.##:19999′.
2015-07-09 20:26:21.829 [Trace] – RetrieveConnection by remoteEndPoint=’###.###.###.##:19999′ and connectionType=’TCP’. No matching connection was found.
2015-07-09 20:26:21.829 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.829 [Trace] – Establishing new connection with [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.829 [Trace] – Connecting TCP client with [TCP] ###.###.###.##:43709 -> ###.###.###.##:19999
2015-07-09 20:26:21.829 [Trace] – Checking for existing connection by endPoint=’###.###.###.##:19999′ and connectionType=’TCP’
2015-07-09 20:26:21.829 [Trace] – Listening for incoming data from [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999
2015-07-09 20:26:21.829 [Debug] – Sending connnectionInfo to [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999
2015-07-09 20:26:21.829 [Trace] – … creating comms packet. PacketObject data size is 46 bytes
2015-07-09 20:26:21.829 [Trace] – Entering packet send of ‘ConnectionSetup’ packetType to [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999. PacketCheckSum=3B6E63FE960DA69D8F202F3B735D49C6
2015-07-09 20:26:21.829 [Debug] – Sending a packet of type ‘ConnectionSetup’ to [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999 containing 86 header bytes and 46 payload bytes. Allowing 1000.0 ms/KB for send.
2015-07-09 20:26:21.829 [Trace] – … 0.129KB written to TCP netstream at average of InfinityKB/s. Current:0.00 ms/KB, AVG:0.00 ms/KB.
2015-07-09 20:26:21.829 [Trace] – Completed packet send of ‘ConnectionSetup’ packetType to [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999
2015-07-09 20:26:21.898 [Debug] – Closing connection with [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999 from [-2].
2015-07-09 20:26:21.927 [Trace] – Entering RemoveConnectionReference for [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999
2015-07-09 20:26:21.927 [Trace] – Removed connection reference by endPoint for [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999
2015-07-09 20:26:21.927 [Debug] – Closing connection with [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999 due to error from [44].
2015-07-09 20:26:21.953 [Trace] – Entering RemoveConnectionReference for [TCP] ###.###.###.##:43710 -> ###.###.###.##:19999
2015-07-09 20:26:21.971 [Error] – Caught ConnectionSetupException while trying to establish a connection with ###.###.###.##
Connection was closed during establish handshake.
2015-07-09 20:26:21.971 [Debug] – Will try connection with ###.###.###.##I am using NLog as sourcecode.
I am using protobuf-net also as source-code.
And I am using NetworkComms.net also as source-code.Mentions:
* the server uses NetworkComms.AppendGlobalIncomingPacketHandler to handle the packets arrived
* while the clients (each client is a new object) will try something like this: if (!conn.IncomingPacketHandlerExists(“ChatMessage”)) PerformerConnection.AppendIncomingPacketHandler<ChatMessage>(“ChatMessage”, HandleIncomingChatMessage, NetworkComms.DefaultSendReceiveOptions);The general close reasons come from calls like the following:
CloseConnection(true, 13); // because of a catch (ObjectDisposedException)CloseConnection(true, 44); // in EstablishConnection, catches the generic Exception
and here:
if (ConnectionInfo.ConnectionState == ConnectionState.Shutdown) throw new ConnectionSetupException(“Connection was closed during establish handshake.”);
Could you please let me know what am I missing?
July 10, 2015 at 12:42 #3962AnonymousInactiveHello guys,
Don’t mind reading, there was an issue on my side as I expected that listening to 0.0.0.0 would actually listen to all IPs/interfaces (which was a wrong assumption) so the issue was tho that the server only listened to 0.0.0.0 – thus the errors.
Many thanks.
July 12, 2015 at 20:43 #3968AnonymousInactiveThank-you for the follow up.
Kind regards,
-
AuthorPosts
- You must be logged in to reply to this topic.