OPC UA Connection to IP Address (when hostname couldn't be resolved) - opc-ua

I'm trying to connect to OPC UA Server which is located over local intranet, though the OPC Server is exposing the Computer Name as a hostname when trying to connect through the given IP address and eventually error out as hostname can't be resolved.
While on the other side, Prosys OPC UA Client can successfully connect to it. I'm currently using Eclipse Milo, but would like to understand how other clients connect to IP Address rather than the hostname while I couldn't?

Asked and answered here: Java OPC-UA Client Eclipse Milo endpoint URL changes to localhost
Instead of using the sample code in that post there is now a helper method in EndpointUtil.updateUrl that you can use.

Related

Connection refused by PLC when connecting with Milo OPC Client

I tried to clean up the ReadExample mini project for client repository from Milo OPC, and for endpoint i put the PLC ip address.
But there was no port in the plc configuration that i could configure.
When i do not specify a port, it says i cannot open a port to it.
If i specify a port, it says connection refused by the machine.
Is it possible to connect the client to the plc? or was i just hoping?
Also, i did remove the server part from the example, as stated in some other questions here about this subject.
Does the PLC have an embedded OPC UA server? Have you tried the default port 4840 yet?

OPC-UA server in a remote access computer

I am trying to connect an OPC-UA server with an OPC-UA client. I am using a remote desktop connection. Is it the reason that I am not getting any server discovered by Matlab OPC UA or Aspen CIMIO even though they are running?
"Discovered" or just "connected"? Connecting to the remote OPC UA server is normal process so if you cannot connect I would check if there is connection can be made in the first place (firewall) and if certificate is used and what is policy.
Can you put the server on your local computer and check the connection then?

Address Already in Use: Bind Exception

I'm using the open source OPC UA client/server implementation of Eclipse Milo. I got a S7-1500 Siemens PLC configurated with a IP address, Port number and Urn name.
To test the Milo Client ReadExample I changed the server configuration settings so that instead of making it's own default server it would connect to the Siemens PLC.
I did but instead of seeing and reading from the PLC it gives an exception.
The ReadExample is running through the ClientExampleRunner where the configuration of the server is called. I first cleaned the project and after that I only runned the ReadExample
Only now after some instruction I commented the calls to the ExampleServer, where the configuration is made, out and changed the endpoint to the address of the PLC.
Don't forget to comment out the exampleServer.shutdown().get() at the end because it will give you an error.

Socket mirror from dynamic IP to a server

Scenario:
I need to have access to a socket server from internet. This server is on a machine that can have a dynamic IP and can be behind router NAT etc and I don't want to configure "port forwarding" dynamic DNS for going out.
My idea is to run socket in a server that client (app) and machine with dynamic IP can connect and the server create data channel from client and master.
Master ----- Socket Mirror with DNS ---- Client (can be more than one)
what is the best way to do this? Backend service like google cloud services? or other ?
The thing you are discussing is about to implement a TCP tunnel, since the question is more general I can't answer with code; I recommend services like ngrok, where it establishes a tunnel between remote server & dynamic IP server, the software is opensource.
NOTE: if you need answer specific to languages search with TCP tunnel.

How does a client socket application identify the server application on the same host computer

I have been trying to learn socket programming in C++ and got some progress for the basics. But I understood that basics are not fundamentals.
One of those fundamentals is about the question which is stated in the title. Lets say I have two separate applications running on the same computer. One of them has a server socket and the other one has a client.
When the server gets an IP address automatically, how can client find the server? Do I have to assign an IP address that is known by the client? In that case, maybe that IP address is not available on the network.
Or can client find and connect to the server by sone kind of name or id?
Have the server bind to all interfaces and have the client lookup 'localhost' by name; it's resolved locally, (ie. no external DNS service required), to an IP address stored in a 'hosts' file, and is set by default to 127.0.0.1
Google 'hosts file'
The IP address of any server in the same host is 127.0.0.1 unless the server has bound to a specific, different IP address. As #MartinJames points out, you can use 'localhost' as the hostname for that, except on certain broken Linux distributions.