18:11, EEST
May 3, 2018
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.
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
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/:?]
13:59, EEST
April 17, 2013
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.
Most Users Ever Online: 1919
Currently Online:
14 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: 729
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech KubalaModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1