linux - FreeOPCUA python client example -
i using freeopcua write simple client example. first tested in laptop running server code , running client code linux in raspberry pi3. able connect server .
now have plc running b&r server. need connect server , attributes value everytime try connect shows connection refused error
. server running fine because have tested using client software on windows not connecting in linux. using freeopcua client example connect server.
do need enable port on trying communicate.?
does have experience in this. please help. thanks.
edit:
the ip address 192.168.1.21 , port number 135. doing below:
client = client("opc.tcp://192.168.1.21:135/") client.connect() #this gives error of connection refused.
i opened client.connect() , found out has below functions:
connect_socket() send_hello() open_secure_channel() create_session() activate_session()
so instead of doing client.connect()
did client.connect_socket()
went ok , didnt gave error. print(client.get_root_node())
showed me node(twobytenodeid(i=84))
, print(client.get_server_node())
shows node(fourbytenodeid(i=2253))
. these values. can consider able connect server doing client.connect_socket()
.
when tried endpoints using client.get_endpoints()
gave me below error:
traceback (most recent call last): file "<stdin>", line 1, in <module> file "opcua/client/client.py", line 299, in get_endpoints return self.uaclient.get_endpoints(params) file "opcua/client/ua_client.py", line 323, in get_endpoints data = self._uasocket.send_request(request) file "opcua/client/ua_client.py", line 76, in send_request data = future.result(self.timeout) file "/usr/local/lib/python2.7/dist-packages/concurrent/futures/_base.py", line 431, in result raise timeouterror() concurrent.futures._base.timeouterror
also when tried open_secure_channel()
or create_session()
or other gave me above error.
i had same problem. found out hello message setting maxmessagesize
, maxchunkcount
0. changed freeopcua
code set same values used uaexpert
, , worked.
so in freeopcua
code, in freeopcua/ua/uaprotocol_hand.py
, changed init of hello class:
class hello(uatypes.frozenclass): def __init__(self): self.protocolversion = 0 self.receivebuffersize = 65536 self.sendbuffersize = 65536 self.maxmessagesize = 16777216 self.maxchunkcount = 5000 self.endpointurl = "" self._freeze = true
if don't know how edit python package, mine located here: c:\users\username\appdata\local\programs\python\python36-32\lib\site-packages\opcua\ua
basically python_directory\lib\site-packages\opcua\ua
edit: open_secure_channel() working before made change, may have different problem. before change create_sessions() , get_endpoints() fail.
Comments
Post a Comment