- This topic has 13 replies, 4 voices, and was last updated 10 years, 4 months ago by Anonymous.
-
AuthorPosts
-
January 8, 2014 at 04:45 #1393AnonymousInactive
I have one windows service that is creating a TCP listener on port 10000 liek this:
TCPConnection.StartListening(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10000));
…and another service that is attempting to connect to it using the following code:
NetworkComms.SendObject("Plugin", "192.168.1.147", 10000, MyMessageToSend);
This connection seems to fail with the following error:
Error during TCP connection establish with destination ([TCP] Local -> 192.167.1.147:10000). Destination may not be listening or connect timed out. System.NullReferenceException: Object reference not set to an instance of an object. at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult) at NetworkCommsDotNet.TCPConnection.ConnectSocket() in c:\Users\Karnifexx\Documents\Visual Studio 2010\Projects\networkcomms.net\NetworkCommsDotNet\Connection\TCP\TCPConnectionCreate.cs:line 336
Any help on what may be causing this error would be great. I tinkered around with the firewall on both machines, but Wasn’t able to get it to connect at all.
January 8, 2014 at 06:26 #1394AnonymousInactiveTCPConnection.StartListening(new IPEndPoint(IPAddress.Parse(“192.168.1.147”), 10000));
January 8, 2014 at 06:54 #1395AnonymousInactiveThank you for the reply, but that did not seem to make any difference. The error occurs on the attempted connection, not when setting up the listener.
January 8, 2014 at 07:22 #1397AnonymousInactiveServerCode
IPEndPoint thePoint = new IPEndPoint(IPAddress.Parse(“192.168.1.147”), 10000);
TCPConnection.StartListening(thePoint, false);
Client Code
ConnectionInfo connInfo = new ConnectionInfo(“192.168.1.147”, 10000);
Connection newTcpConnection = TCPConnection.GetConnection(connInfo);
January 8, 2014 at 16:45 #1399AnonymousInactiveHeyup Guys,
Many thanks for the help msdc123. The following code is correct for listening on port 10000:
TCPConnection.StartListening(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10000));
but it is important to know that if port 10000 is unavailable, NetworkComms.Net will automatically fail over to a random port. If a port is unavailable and you would rather have an exception when calling TCPConnection.StartListening.
The solution is to check which port was used on the server:
Console.WriteLine("Listening for messages on:"); foreach (System.Net.IPEndPoint localEndPoint in Connection.ExistingLocalListenEndPoints(ConnectionType.TCP)) Console.WriteLine("{0}:{1}", localEndPoint.Address, localEndPoint.Port);
Once you have confirmed the correct listening port, if you still have problems, please post back.
Regards,
MarcJanuary 8, 2014 at 23:47 #1403AnonymousInactiveI made a slight change that msdc123 posted to have my client use the following:
Connection newTcpConnection = TCPConnection.GetConnection(new ConnectionInfo("192.168.1.147", 10000)); newTcpConnection.SendObject("Plugin", myObject);
I also used the same code snippet from one of the tutorials to get the addresses and port that the server is listening on and i get the following output:
Service listening for TCP connection on: fe80::5efe:192.168.1.147%10:10000 Service listening for TCP connection on: fe80::186f:3e8a:cd51:7732%9:10000 Service listening for TCP connection on: 2001:0:5ef5:79fb:186f:3e8a:cd51:7732:10000 Service listening for TCP connection on: 127.0.0.1:10000 Service listening for TCP connection on: ::1:10000 Service listening for TCP connection on: 192.168.1.147:10000 Service listening for TCP connection on: fe80::50e3:36de:8e19:fd02%3:10000 Service listening for TCP connection on: fe80::4810:e1e5:8958:860c%4:10000 Service listening for TCP connection on: fe80::f03a:5a2:9fa3:c9f9%6:10000 Service listening for TCP connection on: fe80::acac:cf14:e233:959b%7:10000
I see the address and port I am trying to connect with in that list so to me it seems like it should be working but I still get the following error:
DPSBase.ConnectionSetupException: Error during TCP connection establish with destination ([TCP] Local -> 192.167.1.147:10000). Destination may not be listening or connect timed out. System.NullReferenceException: Object reference not set to an instance of an object. at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult) at NetworkCommsDotNet.TCPConnection.ConnectSocket() in c:\Users\Karnifexx\Documents\Visual Studio 2010\Projects\networkcomms.net\NetworkCommsDotNet\Connection\TCP\TCPConnectionCreate.cs:line 336 at NetworkCommsDotNet.TCPConnection.ConnectSocket() in c:\Users\Karnifexx\Documents\Visual Studio 2010\Projects\networkcomms.net\NetworkCommsDotNet\Connection\TCP\TCPConnectionCreate.cs:line 349 at NetworkCommsDotNet.TCPConnection.EstablishConnectionSpecific() in c:\Users\Karnifexx\Documents\Visual Studio 2010\Projects\networkcomms.net\NetworkCommsDotNet\Connection\TCP\TCPConnectionCreate.cs:line 185 at NetworkCommsDotNet.Connection.EstablishConnection() in c:\Users\Karnifexx\Documents\Visual Studio 2010\Projects\networkcomms.net\NetworkCommsDotNet\Connection\ConnectionCreate.cs:line 150 at NetworkCommsDotNet.TCPConnection.GetConnection(ConnectionInfo connectionInfo, SendReceiveOptions defaultSendReceiveOptions, TcpClient tcpClient, Boolean establishIfRequired) in c:\Users\Karnifexx\Documents\Visual Studio 2010\Projects\networkcomms.net\NetworkCommsDotNet\Connection\TCP\TCPConnectionCreate.cs:line 142 at OSAE.ClientService.ClientService.LoadPlugins() in c:\Users\Brian\Developement\Open Source Automation\Services\ClientService\ClientService.cs:line 205
January 9, 2014 at 00:42 #1405AnonymousInactivecan you tell me your .net framework version.
January 9, 2014 at 00:48 #1407AnonymousInactiveI am using .NET 4.0. Both my Client and server are built using 4.0 and I am using the 4.0 version of the networkcomms dll
January 9, 2014 at 01:12 #1408AnonymousInactiveI don’t konw why ,my code works fine in my computer.
If you are convenient,you can send the project to my email wenjie5816@yhaoo.com .
I will test it
January 9, 2014 at 02:36 #1410AnonymousInactiveI have narrowed the problem down a bit. I took the getting strated tutorial to create the client console application and I able able to successfully send a TCP message to my windows service that is has the TCP listener started.
The problem is obviously with my client. I am a little lost on what to try since I am using exactly the same line of code as the tutorial’s console app.
When my server gets the message from the console application it logs it as such:
A message was recieved from [TCP] 192.168.1.147:10000 -> 192.168.1.101:2719 (cRsAB8gSbEqRdU-FRjlPZg) which said 'This is message #1'.
The error from my client has this:
Error during TCP connection establish with destination ([TCP] Local -> 192.167.1.147:10000)
It looks like maybe the connection is messed up somehow?
-
AuthorPosts
- You must be logged in to reply to this topic.