Bhavana
Bhavana

Reputation: 1054

Connectex: Error connecting to a physical device

I am trying to communicate with a device (connected using ethernet) using TCP/IP connection. When a connection request is sent, I am getting an error:

dial tcp 192.168.137.10:502: connectex: A connection attempt failed because
the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to respond

But if I am connecting to the simulator (which will act as device), it is getting connected and sending me response.

I am using GO for coding. This is my code to connect to device

conn, err := net.Dial("tcp", "192.168.137.10:502")
if err != nil {
  return nil, err
} else {
  return conn, nil
}

Hardware Info:

Upvotes: 2

Views: 1552

Answers (1)

Stephan
Stephan

Reputation: 69

I suspect that there is a problem with the server and not your client code. The fact that you aren't just getting a "connection refused" error tells me that the remote port is probably open. Chances are that the server is not performing an accept() on the incoming connection within a reasonable time.

Things that might cause this

  • Maximum number of connection configured on the server has been exceeded or the service is too busy.
  • Server has crashed
  • Funny firewall or another routing issue between you and the server. Some deep packet inspection firewalls sometimes cause these types of issues.

I suggest you try and do troubleshooting on the server side.

Upvotes: 1

Related Questions