Comments (7)
I think the best thing I could do here is make it so OpcUaServer#getHostnames(String)
is user-configurable.
I don't think there's any implementation we could come up with that would satisfy every use case.
For example, I can see your logic about the canonical hostname being included in the endpoints being confusing since we're bound to localhost, but without including it that would prevent an OPC-UA client application running on the same machine from accessing the server at my-host:4840
, which seems overly strict to me.
from milo.
My original thought when writing getHostnames()
was to lean towards being lenient/flexible, including as many hostnames in the endpoints as I reasonably could.
In the real world we've found that the majority of servers end up being configured (or misconfigured...) with either incorrect or unreachable hostnames in the endpoints, which has lead to pretty much all UA client application implementations having logic that replaces the hostname in the endpoints provided by servers with the hostname/address used to get the endpoints in the first place.
from milo.
I just ran into the problem using open62541 and I think that I identified the problem.
You are using the value of bindAddress
to create the socket here:
https://github.com/eclipse/milo/blob/master/opc-ua-stack/stack-server/src/main/java/org/eclipse/milo/opcua/stack/server/tcp/UaTcpStackServer.java#L148
String bindAddress = endpoint.getBindAddress().orElse(endpointUri.getHost());
I just hacked it to test with:
String bindAddress = endpointUri.getHost();
and tadaaa, it works. In ubuntu the local IP for the hostname is 127.0.1.1
compared to localhost 127.0.0.1
[main] INFO org.domain.UaServer - startDiscoveryServer()
[main] INFO org.eclipse.milo.opcua.sdk.server.namespaces.OpcUaNamespace - Loaded nodes in 589ms.
[main] INFO org.eclipse.milo.opcua.sdk.server.NamespaceManager - added namespace index=0, uri=http://opcfoundation.org/UA/
[main] INFO org.eclipse.milo.opcua.sdk.server.NamespaceManager - registered and added namespace index=1, uri=urn:domain:opcua:discovery:server
[main] INFO org.eclipse.milo.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://my-host:4840 to localhost [None/None]
[main] INFO org.eclipse.milo.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://localhost:4840 to localhost [None/None]
[main] INFO org.eclipse.milo.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://127.0.0.1:4840 to localhost [None/None]
[main] INFO org.eclipse.milo.opcua.sdk.server.OpcUaServer - eclipse milo opc-ua stack version: dev
[main] INFO org.eclipse.milo.opcua.sdk.server.OpcUaServer - eclipse milo opc-ua sdk version: dev
[main] INFO org.eclipse.milo.opcua.sdk.server.NamespaceManager - registered and added namespace index=2, uri=urn:eclipse:milo:opcua:test-namespace
[main] INFO org.eclipse.milo.opcua.stack.server.tcp.UaTcpStackServer - opc.tcp://my-host:4840 bound to /127.0.1.1:4840 [None/None]
[main] INFO org.eclipse.milo.opcua.stack.server.tcp.UaTcpStackServer - opc.tcp://localhost:4840 bound to /127.0.0.1:4840 [None/None]
[main] INFO org.eclipse.milo.opcua.stack.server.tcp.UaTcpStackServer - opc.tcp://127.0.0.1:4840 bound to /127.0.0.1:4840 [None/None]
Is there a specific reason why you are using getBindAddress()
instead of endpointUrl.getHost()
?
from milo.
I think I set a bad example in the ExampleServer
implementation by using "localhost" as a bind address.
The intention is that bind addresses are always configured as IP addresses and not as a hostnames because I want the addresses the server is configured to bind to to be un-ambiguous.
From there, the server tries to intelligently figure out what hostnames and endpoint URLs to use (the getHostnames() function I'm talking about making extensible).
from milo.
Hmm, maybe you could ad a check if the value of setBindAddresses([])
is a hostname or IP and then warn the user.
But I think that the cleaner solution is to use the endpoint.getHost() to bind to, because then the OS has to figure out the correct ip.
And yes, the example should be changed then :)
from milo.
But I think that the cleaner solution is to use the endpoint.getHost() to bind to, because then the OS has to figure out the correct ip.
The whole point is I don't want the OS to figure it out. In a system with multiple NICs I need to be able to be very specific about which address I'm binding to, and then there's room to be less strict on top of that by allowing more than one endpoint URL to point to that NIC.
So I think this is making my point about there not being one solution that will please all... I'll figure out how to make this more configurable.
from milo.
@Pro if you get a chance, check out this PR/branch and see if you can accomplish what you need with it. I'll leave the PR open for a few days before merging it.
from milo.
Related Issues (20)
- Missing Constraint when using as bundle in OSGi context
- Client stack - Reconnection does not restart subscriptions properly HOT 6
- The server has reached its maximum number of sessions HOT 1
- Error when connect to OPC UA server with long URL? HOT 1
- package not found [org.opcfoundation.opcua.binaryschema] HOT 2
- When subscribed to data changes and then read a value from the OPC-UA server, it will continue to receive subscribed data even if its value has not changed HOT 1
- The connection to S7 1500 gets interrupted while the connection to S7 1200 does not. HOT 1
- Get Bad_ArgumentsMissing instead of Bad_TooManyArguments HOT 1
- cant't write a Long value to opc-ua(the data type is UInt32) HOT 1
- Force TCP reconnect after SessionFsm keep-alive failure HOT 2
- Security upgrade to netty-4.1.105.Final
- CertificateValidationUtil issuer certificate KeyUsage checks
- How to read CustomStructType? HOT 1
- Remove dependency on lombok
- milo version 0.6.11 monitors the approximate limit of the number of PLC points HOT 1
- URI Reading Error HOT 8
- Port forwarding HOT 1
- Milo 0.6.12 Gradle ambiguity error for guava 33 HOT 4
- EndpointDescription is only chosen based on path, not hostname, preventing different certificates per-endpoint HOT 2
- status=Bad_Timeout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from milo.