duanbiyi7319 2018-03-20 12:39 采纳率: 100%
浏览 603

Connectex:连接到物理设备时出错

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:

  • Windows 10, 64 bit machine
  • PLC device connected over TCP/IP
  • 写回答

1条回答 默认 最新

  • doushuo8677 2018-03-20 13:06
    关注

    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.

    评论

报告相同问题?