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: 983
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: 983
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: 518

Currently Online:
22 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1