Connection Timed Out using TCP/IP Socket

Hello there,

i’m new to UR and i’m testing my connection to a UR10. I have setup a program THAT WORKS from which i can send script and commands to the UR via socket (IP of my UR is static on a ethernet network, port is 30002, entry point is my machine). I have a script which tries to connect to a another process i have setup to listen the UR request. The code for openning the socket is something like this:

  $ 1 "port≔12345"
  global port=21
  $ 2 "ip_addr≔'169.254.150.55'"
  global ip_addr="169.254.150.55"
  $ 3 "socket≔socket_open(ip_addr,port,'conn')"
  global socket=socket_open(ip_addr,port,"conn")
  $ 4 "Loop socket≟ False "
  while (socket ==   False  ):
    $ 5 "socket≔socket_open(ip_addr,port,'conn')"
    global socket=socket_open(ip_addr,port,"conn")
  end

And the python listener goes like this:

import socket
import time

HOST = "localhost" 
PORT = 21 

print("Starting Program")
count = 0

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT)) # Bind to the port 
s.listen(5) # Now wait for client connection.
c, addr = s.accept() # Establish connection with client.
print(f"Connection from: {addr}")

There is more code but this all that is needed. I tried changing the HOST to 127.0.0.1 and the IP on the ethernet interface . Any idea why is giving me a timeout connection? Also i have a wireshark set up and this is what it shows me:

UR IP: 169.254.177.55
Machine IP: 169.254.150.55
Listener Port: 21

NOTE: the script that runs the program on the UR that tries to establish a connection i tried it from running it from the teach pendant directly and from sending through my tool that works (so the UR is on Remote mode).

Thx in advance

Maybe same problem here:

I’ll try it on monday but i think it won’t give me a result as the problem is that the UR, acting as a client, won’t connect to the machine but doing it the other way around it works. Eitherway, thanks and i will keep the post updated with the results.

The problem is that your Python program isn’t listening on the ethernet interface, it is only listening on the loopback interface ("localhost" or "127.0.0.1"). The solution is to change HOST to "", which will listen on all interfaces, or "169.254.150.55" which will listen only on the ethernet interface connected to the robot.

See the second bullet point on this page.