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
Timeout for connecting
May 3, 2018
18:11, EEST
Avatar
marczona
New Member
Members
Forum Posts: 1
Member Since:
May 3, 2018
sp_UserOfflineSmall Offline

Hello,

We want to connect to a OpcUa Server which is *not* reachable on network. As expected the call to UaClient.connect fails.
Between the call to “connect” and the Exception it takes around 20 seconds. That is to long for our application.
How can I reduce the Timeout?

I have set every timeout I found, but nothing changed.

import com.prosysopc.ua.client.UaClient;
private static final long TIMEOUT_1_SEC = 1000;

UaClient client = ….
client.setTimeout(TIMEOUT_1_SEC );
client.setSessionTimeout(TIMEOUT_1_SEC );
client.setStatusCheckTimeout(TIMEOUT_1_SEC);
client.getEndpointConfiguration().setOperationTimeout((int) TIMEOUT_1_SEC);
client.setPublishRequestTimeout(TIMEOUT_1_SEC);
client.connect();

When I debug into java.net.AbstractPlainSocketImpl I see a timeout around 60000 (ms?).
We use Java SDK Client 2.2.6.

Regards,
jonas

Caused by: com.prosysopc.ua.client.ConnectException: Failed to retrieve endpoints. The server is not available: opc.tcp://xxx.xx.xxx.xxx:xxxx
at com.prosysopc.ua.client.UaClient.discoverEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.discoverEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.getEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.u(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.connect(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at de.berg.amrconnector.webservice.blm.OpcConnectionUtils.createClient(OpcConnectionUtils.java:236) ~[classes/:?]
… 31 more
Caused by: org.opcfoundation.ua.common.ServiceResultException: Bad_ConnectionRejected (code=0x80AC0000, description="2158755840, Connection timed out: connect")
at org.opcfoundation.ua.transport.tcp.io.TcpConnection.open(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.open(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.application.Client.createSecureChannel(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.application.Client.createSecureChannel(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.application.Client.createSecureChannel(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at com.prosysopc.ua.client.UaClient.discoverEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.discoverEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.getEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.u(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.connect(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at de.berg.amrconnector.webservice.blm.OpcConnectionUtils.createClient(OpcConnectionUtils.java:236) ~[classes/:?]
… 31 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[?:1.8.0_92]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[?:1.8.0_92]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_92]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[?:1.8.0_92]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_92]
at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_92]
at org.opcfoundation.ua.transport.tcp.io.TcpConnection.open(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.open(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.application.Client.createSecureChannel(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.application.Client.createSecureChannel(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at org.opcfoundation.ua.application.Client.createSecureChannel(Unknown Source) ~[opc-ua-stack-1.02.337.10.jar:1.02.337.10]
at com.prosysopc.ua.client.UaClient.discoverEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.discoverEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.getEndpoints(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.u(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.connect(Unknown Source) ~[opc-ua-client-2.2.6-708.jar:2.2.6.708]
at de.berg.amrconnector.webservice.blm.OpcConnectionUtils.createClient(OpcConnectionUtils.java:236) ~[classes/:?]
May 4, 2018
13:59, EEST
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello,

Unfortunately you cannot set the secure channel creation timeout yourself in the current version. This would be a good feature and something that will probably be introduced in the future.

The default timeout used in the Stack is indeed 60 seconds. The timeout of ~20 seconds that you experience is the default timeout of the operating system. Anyways, the issue is not the absolute value of the timeout but the fact that it cannot be easily set by the user of the SDK.

As a workaround, I would suggest that you create your own application level timeout for the client.connect() method. However, it’s good to note that the client.connect() does a bunch of initializations and it can take a few seconds also in a normal connection scenario.

As another workaround, you could try creating your own plain Java Socket connection with a small timeout value. Then if the socket connection succeeds, you know that the server is listening for connections. This is kind of a hack but if you really need to have a small timeout value, this may be a viable option.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 685

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1466

Posts: 6256

Newest Members:

Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule, rashadbrownrigg, christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer

Moderators: Jouni Aro: 1009, 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: 320, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1