Socket_open connection doesn't work UR10e

Hello,

i am trying to do a commucation between Cobot and PC with python.

For that I wrote a Python script …

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
HOST = "192.168.41.42"
PORT = 30000
s.bind((HOST, PORT))
s.listen(1)

try:
   while True:
       komm, addr = s.accept()
       while True:
           data = komm.recv(1024)
           if not data:
               komm.close()
               break
           print("[{}] {}".format(addr[0], data.decode()))
           nachricht = input("Antwort: ")
           komm.send(nachricht.encode())
  finally:
    s.close()

On my cobot I tried to connect with server_open(“192.168.41.42”, 30000, “socket”)

Somehow the connection doesn’t work.

komm, addr = s.accept()    The program on the PC doesn't get past this point. 

server_open(“192.168.41.42”, 30000, “socket”) The program on the cobot can't connect via this command

but the Network connection is possible. Because I can ping the cobot from the PC.

Can anyone tell me what I am doing wrong?
Thank you!!

Hello,

Actually the best way to communicate with the robot, is to use the given features of UR.
You can use the RTDE and Dashboardserver to read everything you need from robot.
Then there is a Primary and secondary interface you also can use to send commands.

Check out here for RTDE
https://www.universal-robots.com/articles/ur/interface-communication/real-time-data-exchange-rtde-guide/

and here you have an overview of client interfaces.
https://www.universal-robots.com/articles/ur/interface-communication/overview-of-client-interfaces/

Thank you, I will look into that

Something that I read on a similar issue was that the PC running the python script was a Windows machine and the firewall didn’t allow the connection. So the process had to be added to the firewall exceptions.