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
Sample Server not binding to all IPs
September 10, 2012
20:25, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

I’ve been running the sample server on the same machine as the client, and now I’m moving it to a different machine.
The old machine was Win7, and the new machine is Debian. This line should bind the server to all network adapters, correct?

// Add the IP address(es) of the server host to the endpoints
server.setUseAllIpAddresses(true);

When I run on the Windows machine, I see lines like this in the log for each network adapter:
09/10/2012 16:08:33.060 INFO Server endpoint bound to opc.tcp://192.168.8.141:52520/OPCUA/TimsServer
09/10/2012 16:08:33.061 INFO Discovery endpoint bound to opc.tcp://192.168.8.141:52520

When I run on the Linux machine, I only see bindings for localhost, storm(the machine name), and 127.0.0.1.
I don’t get a line for the actual IP, which is 192.168.1.50. Here’s the output of netstat:

root@storm:/opc/server# netstat -lptu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 localhost:52520 *:* LISTEN 8693/java

It looks like I can only connect from localhost. Am I doing something wrong?
Is there something I need to do to force the server to bind to the external IP address?

September 11, 2012
7:23, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

There seem to be differences in the Java network/socket implementation in different environments and JDKs.

However, it does not really matter that much any more(*) which endpoint URLs the server is bound to, since the clients will need to be able to pick up a useful endpoint anyway. So as long as your client can connect to the server port, it should be able to use any of the endpoints that are available, for example, the one bound to the host name.

See also http://www.prosysopc.com/blog/…..t-machine/, which was a bit similar issue.

(*) The first implementation of the Java CLient side required that there must be an exactly same endpointUrl defined in the server to which the client was connecting to. Since this will prevent connecting to server behind NAT addresses this has been changed to be less restrictive. The client will check the server certificate instead, to ensure that it is not connecting to a “fake server”. Still, you will see a warning in the client side log, if the endpointUrl is different to what is used for connecting.

September 11, 2012
8:33, EEST
Avatar
Rico
Member
Members
Forum Posts: 4
Member Since:
September 5, 2012
sp_UserOfflineSmall Offline

Jouni Aro said

There seem to be differences in the Java network/socket implementation in different environments and JDKs.

However, it does not really matter that much any more(*) which endpoint URLs the server is bound to, since the clients will need to be able to pick up a useful endpoint anyway. So as long as your client can connect to the server port, it should be able to use any of the endpoints that are available, for example, the one bound to the host name.

See also http://www.prosysopc.com/blog/…..t-machine/, which was a bit similar issue.

@TimK: I got the same problem and get it around by replacing the linux machine hostname in /etc/hostname with the current IP@ of the bound IP interface.

check with hostname -f and check the INFO messages from log4j you should see the endpoints bindings with the locahost one (if activated on the server side by server.getSetUseLocalhost(true) and the “IP” one as for your Windows log.
yet , I think this is not the “proper” way of doing … 😉
seems like the resolv and etc/hosts are not checked … (?)
Eric

September 11, 2012
12:43, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

I guess I left out the most important detail 🙂
That’s the problem I’m seeing, Jouni – I can’t connect to the port from another machine. The socket doesn’t seem to be bound to the external IP address. I just get Connection Refused.

September 11, 2012
14:08, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

OK, that may be the case, at least if you have several interfaces, I suppose.

You can try to add the endpoint manually: after server.init() call server.addEndpoint() with your endpoint.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
13 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

TimK: 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