How to override advertised endpoint URL for OPC UA server in Docker to connect to clients (MATLAB) on host? #1563
Unanswered
Aditi250199
asked this question in
Q&A
Replies: 1 comment
-
|
set propper hostename of your docker container and server the same!? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am encountering a persistent issue when trying to connect MATLAB to a Python-based OPC UA server running inside a Docker container on my Windows 11 machine. Below are the key details:
System and Software Details
• Host OS: Windows 11 Version 24H2
• Docker Version: 28.0.4
• Python Version (inside Docker): 3.11.13
• python-opcua Package: 0.98.13
• MATLAB Version: R2024b
Setup Summary
• I have a Python OPC UA server running in a Docker container using python-opcua.
• The server is bound to opc.tcp://0.0.0.0:4840 inside the container.
• From the host machine, I try to connect MATLAB using:
uaClient = opcua('opc.tcp://:4840'); OR
uaClient = opcua('opc.tcp://localhost:4840'); OR
uaClient = opcua('opc.tcp://host.docker.internal:4840');
connect(uaClient);
• MATLAB throws the following error:
Error using opcua (line 46)
Unable to receive endpoint from URL opc.tcp://0.0.0.0:4840. Check if hostname can be resolved or try providing the IP address instead of hostname. For more information, see Troubleshooting.
• I tried connecting to my server running inside docker container using UA Expert by manually add endpoint URL (ie using Advanced add url: opc.tcp://host.docker.internal:4840/) .The UA client on host connects and the nodes of the server are read.
However, in the logs the detected endpoint is 172.17.x.x .
Troubleshooting Done
o opc.tcp://0.0.0.0:4840
o Setting application URI and discovery URLs as:
server.set_application_uri("opc.tcp://host.docker.internal:4840")
server.set_discovery_urls(["opc.tcp://host.docker.internal:4840"])
o Binding to host.docker.internal, localhost, and specific IPs : all fail.
The communication incompatibility issue arises only when MATLAB is a client on host machine.
How can I correctly override the advertised endpoint URLs returned in GetEndpoints, so they show host.docker.internal instead of 0.0.0.0?
Is there a clean way to bind and advertise different endpoint addresses using python-opcua?
I’d appreciate any help in resolving this. Thank You.
Beta Was this translation helpful? Give feedback.
All reactions