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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Test connection from Application Client to Thingworx Platform (Java SDK)

dbologna
11-Garnet

Test connection from Application Client to Thingworx Platform (Java SDK)

HI All,

I installed on VM Machine (111.111.111.14) Windows 7 64bit a Thingworx 8.0.3.-b52   and I created a Thing 'TestRemoteThing' using ThinTemplate RemoteThing.

I created another VM Machine (111.111.111.11) Windows 7 64bit where I installed Eclipse and I imported a package Java SDK 221-Java-SDK-6-0-4-595.zip (dowbloaded from PTC Market place)

I'm using the documentation from http://support.ptc.com/help/thingworx_hc/thingworx_edge/index.html.

I Run SimpleClient.java using :

- config.setUri("wss://111.111.111.14:443/Thingworx/WS");

- config.setAppKey("1146b538-3ad5-4977-8679-3f6bf2b55081"); application-key generate on Thingworx

but the connection failed.

Is it necessary a setting on Thingworx platform ?

I run a test WebServices.html and it answer

WebSocket Test

ERROR: undefined

DISCONNECT

 

What is the next check I have to do?

Do I have to install any software on the PC on which Thingworx is installed?

 

Many Thanks

BR

Dimitri

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi All,

I used the following step :

1) stop tomcat

2) create a new directory keystore on c:\<tomcat_pathname>

3) create a self-signed certificate with java keytool running the following command

c:\<path_java>\jre\bin\Keytool -genkey -alias tomcat -keyalg RSA -keystore c:\<tomcat-folder>\keystore\.keystore

using password "changeit" 

4) add the follwing row in C:\<tomcat_pathname>\conf\server.xml 

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"

               maxThreads="150" SSLEnabled="true">

       <SSLHostConfig>

                    <Certificate certificateKeystoreFile="keystore/.keystore" type="RSA" />

       </SSLHostConfig>

</Connector>

5) start Tomcat

6) using IE with url https:/7localhost:8443, click on "Continue to this website (not recmmended) 

 

By 

Dimitri

 

  

 

I create the keystore file into <pathname_tomcar>\kestore\.keystore using the command

c:\<path_java>\jre\bin\Keytool -genkey -alias tomcat -keyalg RSA -keystore <tomcat-folder>\keystore\.keystore

View solution in original post

6 REPLIES 6
supandey
19-Tanzanite
(To:dbologna)

Hi @dbologna I would start checking details in following order

 

- Are all the pre-requisites met as described in the  Setting Up to Run Sample Applications

- Can those two VMs interact with each other? e.g. is VM1 able to ping VM2 and vice versa , ensure connection is somehow not blocked over the network or

- To which user account does this app key belong to? I.e. does it have sufficient access rights assigned to it

- Start debugging your code from the Eclipse IDE together with logs on trace to try and get more specific error stack

 

If you are done with the pre-requisites I don't think there's any separate requirement to install any specific software on ThingWorx server

 

My answers (bold)  at your/her questions ?

 

- Are all the pre-requisites met as described in the  Setting Up to Run Sample Applications.

I’m not using Glade but I’m using Eclipse (https://developer.thingworx.com/resources/guides/thingworx-java-sdk-setup-guide)

- Can those two VMs interact with each other? e.g. is VM1 able to ping VM2 and vice versa , ensure connection is somehow not blocked over the network or

VM1 ping VM2 and vice versa . The firewall on both VM are disabled.

- To which user account does this app key belong to? I.e. does it have sufficient access rights assigned to it

The application key create in Thingworx Platform have ‘Administrator’ as ‘User Name Reference’.

- Start debugging your code from the Eclipse IDE together with logs on trace to try and get more specific error stack

If I’m using config.setUri(“ws://111.111.111.14:80/Thingworx/WS”);  the connection works.

If I’m using config.setUri(“wss://111.111.111.14:8443/Thingworx/WS”);   not work because the tomcat not support SSL/TLS protocol.

I have enabled this protocol by performing the following steps (using the support documentations) :

  1. Stop Tomcat
  2. Generated tomcat.keystore with

keytool -genkey -alias tomcat -keystore tomcat.keystore -keyalg RSA

  1. Move tomcat.keystore to <Tomcat pathname>\conf
  2. Add the following row to server.xml

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"

maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS"

enableLookups="false" keystoreFile="conf/tomcat.keystore" keystorePass=”changeit!" />

  1. Start Tomcat
  2. During the startup of  Tomcat I received the following message inside the tomcat-stderr.log

57 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-8443"]

01-Mar-2018 22:16:01.770 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[HTTP/1.1-8443]]

org.apache.catalina.LifecycleException: Protocol handler initialization failed

  1. The protocol SLL/TLS does not work

I’m using Tomcat 9.0.5 and java 1.8.0_144.

Every suggestion is well received.

BR

Dimitri

supandey
19-Tanzanite
(To:dbologna)

Tomcat 9.0 is not yet officially supported, even though it may work as we see in your case. Would it be possible for you to attach the server.xml file?

PS: With ThingWorx version 8.0 the supported versions are 8.0.x and 8.5

Mant thanks,

I found solution for the following version of Tomcat 8.5.23, 8.5.28 and 9.0.5.

BR

Dimitri

supandey
19-Tanzanite
(To:dbologna)

Thank you Dimitri for updating. Would it be possible to share it here? And you can use that to mark this question as answered.

Hi All,

I used the following step :

1) stop tomcat

2) create a new directory keystore on c:\<tomcat_pathname>

3) create a self-signed certificate with java keytool running the following command

c:\<path_java>\jre\bin\Keytool -genkey -alias tomcat -keyalg RSA -keystore c:\<tomcat-folder>\keystore\.keystore

using password "changeit" 

4) add the follwing row in C:\<tomcat_pathname>\conf\server.xml 

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"

               maxThreads="150" SSLEnabled="true">

       <SSLHostConfig>

                    <Certificate certificateKeystoreFile="keystore/.keystore" type="RSA" />

       </SSLHostConfig>

</Connector>

5) start Tomcat

6) using IE with url https:/7localhost:8443, click on "Continue to this website (not recmmended) 

 

By 

Dimitri

 

  

 

I create the keystore file into <pathname_tomcar>\kestore\.keystore using the command

c:\<path_java>\jre\bin\Keytool -genkey -alias tomcat -keyalg RSA -keystore <tomcat-folder>\keystore\.keystore

Top Tags