Skip to main content
1-Visitor
May 9, 2019
Solved

Connecting Raspberry Pi to Thingworx ERROR

  • May 9, 2019
  • 1 reply
  • 4644 views

Hi Community,

 

I`ve followed the Thingworx Raspberry Pi tutorial but I`m currently stuck at step 5, launching the EMS.

When I try to run it with the command sudo ./wsems I`m getting the following errors:

[FORCE] 2019-05-09 08:46:47,382 ./wsems: Initializing EMS ....
[FORCE] 2019-05-09 08:46:47,382 main: Using config file /home/pi/Desktop/microserver/etc/config.json
[INFO ] 2019-05-09 08:46:47,382 ./wsems: Creating the WsEms proxy.
[INFO ] 2019-05-09 08:46:47,383 ./wsems: Starting HTTP Server.
[WARN ] 2019-05-09 08:46:47,383 Main: Encryption is disabled on HTTP Server.
[WARN ] 2019-05-09 08:46:47,384 Main: Authentication is disabled on the HTTP Server.
[INFO ] 2019-05-09 08:46:47,384 ./wsems: Initializing the ThingWorx8080
[FORCE] 2019-05-09 08:46:47,384 httpServer: Initializing the ThingWorx8080
[INFO ] 2019-05-09 08:46:47,385 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2019-05-09 08:46:47,386 wsEmsProxy::initialize: Encryption is enabled on Web Socket connection.
[WARN ] 2019-05-09 09:46:47,388 SDK: SDK Version: 2.2.0
[WARN ] 2019-05-09 09:46:47,388 SDK: TLS Library: OpenSSL
[WARN ] 2019-05-09 09:46:47,388 SDK: TLS Library Version: 1.0.2l-fips
[WARN ] 2019-05-09 09:46:47,389 SDK: FIPS Capable
[INFO ] 2019-05-09 08:46:47,405 WsProxy::initialize: EMS Version 5.4.5.512
[INFO ] 2019-05-09 08:46:47,405 WsProxy::initialize: twApi singleton initialized
[WARN ] 2019-05-09 08:46:47,405 WsProxy::initialize: Certificate validation is disabled.
[INFO ] 2019-05-09 08:46:47,407 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2019-05-09 08:46:47,409 ./wsems: Starting the connection.

10.128.54.64:8080-->[ERROR] 2019-05-09 09:46:47,417 SDK: TW_NEW_SSL_CLIENT: SSL handshake error. Error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.
[ERROR] 2019-05-09 09:46:47,418 SDK: Error intializing SSL connection
[ERROR] 2019-05-09 09:46:47,418 SDK: twWs_Connect: Error restarting socket. Error 0
[ERROR] 2019-05-09 09:46:52,423 SDK: TW_NEW_SSL_CLIENT: SSL handshake error. Error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.
[ERROR] 2019-05-09 09:46:52,424 SDK: Error intializing SSL connection
[ERROR] 2019-05-09 09:46:52,424 SDK: twWs_Connect: Error restarting socket. Error 0
[ERROR] 2019-05-09 09:46:57,430 SDK: TW_NEW_SSL_CLIENT: SSL handshake error. Error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.
[ERROR] 2019-05-09 09:46:57,430 SDK: Error intializing SSL connection
[ERROR] 2019-05-09 09:46:57,430 SDK: twWs_Connect: Error restarting socket. Error 0
[ERROR] 2019-05-09 09:47:02,437 SDK: TW_NEW_SSL_CLIENT: SSL handshake error. Error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.
[ERROR] 2019-05-09 09:47:02,437 SDK: Error intializing SSL connection
[ERROR] 2019-05-09 09:47:02,437 SDK: twWs_Connect: Error restarting socket. Error 0
[ERROR] 2019-05-09 09:47:07,445 SDK: TW_NEW_SSL_CLIENT: SSL handshake error. Error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.
[ERROR] 2019-05-09 09:47:07,445 SDK: Error intializing SSL connection
[ERROR] 2019-05-09 09:47:07,445 SDK: twWs_Connect: Error restarting socket. Error 0

My config.json  file looks as following:

 

{ 
 "ws_servers": [{
 "host": "10.128.54.63",
 "port": 8080
 }],
 "appKey": "3ad3295d-4dd2-4ca9-84ed-c83edfc70cd3",
 "http_server" : {
 "host": "127.0.0.1",
 "port": 8080,
 "use_default_certificate" : true,
 "ssl" : false,
 "authenticate" : false
 },
 "logger":{
 "level":"INFO"
 },

 "certificates":{
 "validate": false
 }
}

Any ideas what could cause the problems?

 

Thank you!

Best answer by Rick-Stanley

Now that I know a little more about your ThingWorx server I can give a more specific config file. The connection from the EMS to the ThingWorx platform server is specified in the ws_servers and the ws_connection sections. The http_server section specifies the behaviour of a server the EMS starts to allow inbound connecions to it from the LSR. Try this:

 

{
 "ws_servers": [{
 "host": "10.128.54.63",
"port": 8080 }], "appKey": "3ad3298d-4dd5-4ce9-88ed-c83kufc70ze3", "ws_connection": { "encryption": "none" }, "http_server" : {
"host": "127.0.0.1",
"port": 8084,
"ssl" : false,
"authenticate" : false }, "logger":{ "level":"INFO" }, "certificates":{ "validate": false,
"allow_self_signed": true } }

Be sure to add these lines to your config.lua file so LSR can connect to the server in the EMS

scripts.script_resource_ssl = false
scripts.script_resource_authenticate = false

scripts.rap_host = "127.0.0.1"
scripts.rap_port = 8084

 

1 reply

5-Regular Member
May 9, 2019

The EMS tries to connect to the ThingWorx server using TLS/HTTPS by default. Can you browse to your ThingWorx server with this URL? - note the S in https:

https://10.128.54.63:8080/ThingWorx

Because port 8080 is usually used for http connections, I would guess you are not able to connect.

To allow the EMS to connect to an unsecure server, add this to your config:

"ws_connection": {
   "encryption" : "none"
},

 

If you can connect to your ThingWorx server, the problem may be specifying the same port to connect to ThingWorx as the EMS is using to listen for inbound connections. Try changing the port the EMS listens on by changing the port value

"ws_servers": [{
 "host": "10.128.54.63",
 "port": 8081
}],

You may need to make both of these changes. If you change the EMS listening port, be sure to change the LSR config.lua configuration file to match the port where the EMS is listening:

scripts.rap_port = 8081

 

augmentor1-VisitorAuthor
1-Visitor
May 16, 2019

Thanks for your quick reply, I will try it and come back with the results.