Python OPCUA server connection Issue

I can connect with Prosys simultaion server with OPCUA client node in Node Red but when I run python OPCUA it's not at all getting connected Why is it so? Python server - python client is working fine!

Please find the python code below


from opcua import Server
from random import randint
import datetime
import time

server = Server()

url = "opc.tcp://127.0.0.1:4840"
server.set_endpoint(url)

name = "OPC_SIMULATION_SERVER"
addspace = server.register_namespace(name)

node = server.get_objects_node()

Param = node.add_object(addspace, "Parameters")

Temp = Param.add_variable(addspace, "Temperature", 0)
Press = Param.add_variable(addspace, "Pressure", 0)
Time = Param.add_variable(addspace, "Time", 0)

Temp.set_writable()
Press.set_writable()
Time.set_writable()

server.start()
print("Server started at {}".format(url))

while True:
Temperature = randint(10,50)
Pressure = randint(200, 999)
TIME = datetime.datetime.now()

print(Temperature, Pressure, TIME)

Temp.set_value(Temperature)
Press.set_value(Pressure)

Time.set_value(TIME)

time.sleep(0.1)

I am not sure what you are asking. What do you mean by "when I run python OPCUA" and what isn't getting connected to what?

I'm sorry for missing the word "server", there are opcua simulation server in python, I'm not able to connect with opcua-client node in Node-red

I haven't used that node, but I suggest you start by showing us how you have configured the client node and tell us where you are running the server and what OS/hardware node-red is running on. Also post the terminal log that is shown when you start node-red in a terminal. Then probably someone with experience of the node will be able to help.

I installed node-red-contrib-opcua
I will share the working one first, ie: reading from prosys


So that is the working one, I assume. It is the failing one we need.

I note from the screenshot that you appear to be running node-red in Docker. Is that correct? If so I believe that you cannot reference the host via localhost from within the container. I mention that in case that is what you are trying to do.

Hi Colin,

Thanks for the support, Yes the node-red docker only I used, I made it worked I dockerized the python server connect to the same network and its reading now, In addition is there any examples of deploying the docker container in any cloud Kubernetes platform?

I don't know about Kubernetes. There have been posts about that previously so I suggest you start by searching the forum. Then if that doesn't help start a new thread with your question.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.