cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Error connecting Java Edge SDK sample program to Thingworx server:

nkumar-21
1-Visitor

Error connecting Java Edge SDK sample program to Thingworx server:

I am getting the error when I try to run the sample java program bundled in ThingWorx Java SDK.

11:25:46.456 [Client-EndpointMonitor-1] ERROR c.t.c.c.c.n.NettyClientConnectionFactory - Exception occurred while connecting to server

java.util.concurrent.TimeoutException: timeout waiting for websocket handshake to complete

  at com.thingworx.communications.client.connection.netty.NettyClientConnectionFactory$HandshakeCompletionNotifier.await(NettyClientConnectionFactory.java:563) ~[thingworx-communications-client-6.0.0.189.jar:na]

  at com.thingworx.communications.client.connection.netty.NettyClientConnectionFactory.createConnection(NettyClientConnectionFactory.java:309) ~[thingworx-communications-client-6.0.0.189.jar:na]

  at com.thingworx.communications.client.endpoints.ClientCommunicationEndpoint.refillConnections(ClientCommunicationEndpoint.java:225) [thingworx-communications-client-6.0.0.189.jar:na]

  at com.thingworx.communications.common.endpoints.monitor.ConnectivityMonitorTask.dutyCycleOn(ConnectivityMonitorTask.java:150) [thingworx-communications-client-6.0.0.189.jar:na]

  at com.thingworx.communications.common.endpoints.monitor.ConnectivityMonitorTask.run(ConnectivityMonitorTask.java:264) [thingworx-communications-client-6.0.0.189.jar:na]

  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_66]

  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_66]

  at java.lang.Thread.run(Unknown Source) [na:1.8.0_66]

11:25:46.456 [Client-EndpointMonitor-1] INFO  c.t.c.c.c.n.NettyClientConnectionFactory - forcing underlying tcp channel closed [is open: false, is active: false]

11:25:46.457 [Client-EndpointMonitor-1] ERROR c.t.c.c.e.ClientCommunicationEndpoint - Refilling connections on [endpoint 0, uri: wss://localhost:80/Thingworx/WS] failed : timeout waiting for websocket handshake to complete

11:25:46.458 [Client-EndpointMonitor-1] ERROR c.t.c.c.e.ClientCommunicationEndpoint - Exception refilling connections was:

Connection setup information in the java client is as follows:

  config.setUri("ws://localhost:80/Thingworx/WS");

I have tried importing a certificate in tomcat (tomcat listens on port 8443 after that) and changed the connection information as follows:

  config.setUri("wss://localhost:8443/Thingworx/WS");

But that also gives me similar error.

Can some one please guide me how to fix this error?

ACCEPTED SOLUTION

Accepted Solutions
billrei
12-Amethyst
(To:nkumar-21)

This message usually occurs because you have connected to a server that is unable to negotiate a websockets upgrade to your connection. Normally your connection is established on whatever port you specify. In this case you specified port 80 on your local machine. A connection was established but when the SDK asked for this connection to be upgraded from HTTP to websockets, the server did not respond. This can happen if you are talking to a web proxy between you and the server that does not understand websockets but in your case I would like you to confirm that your ThingWorx server is on port 80 and not port port 8080 which is the default. You may already have a server on port 80 that does not support websockets.

View solution in original post

9 REPLIES 9
billrei
12-Amethyst
(To:nkumar-21)

This message usually occurs because you have connected to a server that is unable to negotiate a websockets upgrade to your connection. Normally your connection is established on whatever port you specify. In this case you specified port 80 on your local machine. A connection was established but when the SDK asked for this connection to be upgraded from HTTP to websockets, the server did not respond. This can happen if you are talking to a web proxy between you and the server that does not understand websockets but in your case I would like you to confirm that your ThingWorx server is on port 80 and not port port 8080 which is the default. You may already have a server on port 80 that does not support websockets.

Thanks Bill for the early reply.

I ran the SDK client again in an open Internet environment (without a proxy server between the client and the Thingworx server) and it worked flawlessly.

Hi Bill,

We are also trying to connect java SDK to secured(https) thingworx server and it's working with open network.

Actually we need to connect java SDK to  thingworx server hosted on machine which is available in a private network.

so please provide the steps if there are settings need to be done?

billrei
12-Amethyst
(To:rkandasamy)

The private network must expose thingworx server port (80,8080, 443) on its firewall.

The SDK's need to be able to establish an HTTP or HTTPS connection with the server.

No other ports are required to be open.

rupadhyay
12-Amethyst
(To:billrei)

Hi Bill Reichardt

I am facing similar problem when launching the Edge Server from Raspberry Pi . Its not connecting.

Just to  clarify, I am running Thingworx on Port 8081 on my local laptop I have tried 80 and 81 and 8081 in port in config.js  , however its failing with error :

SELECTED: Basic Thing with Property

Running Example #3: minimal agent w/ property

[Error] Error intializing socket connection.  Err = 113

[Error] twWs_Connect: Error restarting socket.  Error 113

[Error] twMessage_Send: Error sending Message with RequestId 1

[Error] [HomeLight0]: Error calling twApi_WriteProperty() for LightLocation - 1107

[Error] twMessage_Send: Error sending Message with RequestId 2

[Error] [HomeLight0]: Error calling twApi_PushProperties() - 1107

[Error] Error intializing socket connection.  Err = 113

[Error] twWs_Connect: Error restarting socket.  Error 113

[Error] Error connecting - 1001

Your suggestion would be greatly appriciated

billrei
12-Amethyst
(To:rupadhyay)

Is your laptop running windows? Your firewall may be preventing any machine but localhost from connecting to it. Try temporarily suspending your windows firewall and trying to connect. Also, if you have wget or curl installed on your pi, try making a connection to http://<yourupaddress>:8080/Thingworx and see if you get a response or an error.

I am not sure from your question, if you are using an SDK or our ems product but it looks like you might be using the C SDK. Depending on how it was compiled, you may need to call twApi_DisableEncryption() if you are not using https.

Another suggestion would be to increase your logging level. There is not enough log detail to see the cause of your problem. In the C SDK this would be done by calling twLogger_SetLevel(TW_TRACE);

rupadhyay
12-Amethyst
(To:billrei)

Hi Bill Reichardt

Yes , I have  Windows 7 on my Laptop.

I am running Thingworx on Port 8081 rather than 8080.

After disabling firewall , it is connecting as I am getting Connected to Thingworx with Thing 'HomeLight0'.

SELECTED: Basic Thing with Property

Running Example #3: minimal agent w/ property

[Force] twWs_Connect: Websocket connected!

Connected to Thingworx with Thing 'HomeLight0'

Property 'LightStatus' has a value of 'undefined'

[Error] [HomeLight0]: Error calling twApi_WriteProperty() for LightLocation - 1110

[Error] subscribedPropertyUpdateTask - Error getting subscribed properties

[Error] [HomeLight0]: Error calling twApi_PushProperties() - 1110

Thanks for your help , highly Appreciated.

I would also  like to mention that I was successfully able to connect to Thingworx with Java SDK from Eclipse from my laptop  (without disabling firewall by using port 8443 ) .
In this case I was trying to connect Thingworx from Raspberry pi through thingworx-nodejs-agent downloaded from Github.

I will try and  look for workaround for this without disabling firewall

Thanks once again !

mikem1
5-Regular Member
(To:rupadhyay)

In may be the case that Windows firewall is blocking non-TLS connections, but allowing TLS.

rupadhyay
12-Amethyst
(To:mikem1)

Hi Mike , I was able to resolve that issue. Thanks for suggestion though.

Announcements


Top Tags