Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Connect to OPC Server using OPC-UA
May 5, 2021
12:47, EEST
Avatar
hypnos97
Member
Members
Forum Posts: 4
Member Since:
May 5, 2021
sp_UserOfflineSmall Offline

Good morning.

First of all, sorry but I am a novice in all that relates to OPC servers and connections.
I’m trying to connect to Matrikon OPC Server that I have installed and running in a virtual machine, and the same try to connect from the Java SDK against Matrikon server, but i can not.

The next example code (seemingly simple), returns next error on line “client.connect()”: “Failed to retrieve endpoints The server is not available. Opc.tcp: // localhost: 4841 ServiceResult = Bad_ConnectionRejected (0x80AC0000)” Could not Establish a network connection to remote server.

May 6, 2021
14:19, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

That means we could not open a tcp socket connection to that address+port (“localhost: 4841”). Basically resolving that is outside of the scope of the SDK, sort of (i.e. “no one answers on the other end of the line”).

In this case it is “localhost”, thus it is the same machine. Either the server is not running, or uses different port, or the “localhost” resolved to e.g. IPv6 address when the server would only bind to IPv4 address. Typically at least on Win10 addresses tend to nowadays resolve to their IPv6 forms and some servers only bind to IPv4. Thus, could you try with an address of “127.0.0.1” instead of “localhost” to check if this was the case?

In theory we could try both versions in some future version, since we use the address which is the first resolution, sometimes there are multiple ones (meaning we might get both the IPv6 and IPv4 forms and the order depends which the OS prefers). Though this requires some investigations. Personally I would sort of argue that this is the responsibility of the OS etc. But depending how much this problem happens we might need to try both also within SDK (if possible).

One option also is to force java to use IPv4 stack always: https://stackoverflow.com/questions/11850655/how-can-i-disable-ipv6-stack-use-for-ipv4-ips-on-jre, if multiple results are received it would move the IPv4 result before IPv6, and thus we would use the IPv4 one.

May 6, 2021
15:02, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

However, if we are in a situation in the distant future that servers starts to only bind to IPv6 address, then the force “java use IPv4 network stack” option will backfire. So using the raw IP in this case might be the better option, maybe.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 728

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1