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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Connecting Raspberry Pi to Thingworx ERROR

augmentor
14-Alexandrite

Connecting Raspberry Pi to Thingworx ERROR

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!

ACCEPTED SOLUTION

Accepted Solutions

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

 

View solution in original post

6 REPLIES 6

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

 

augmentor
14-Alexandrite
(To:Rick-Stanley)

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

augmentor
14-Alexandrite
(To:Rick-Stanley)

OK you guessed correctly, I can only connect to the Thingworx server with the unsecure (http) URL. 

 

However, after changing the config file, it still shows an error.

I also added "allow_self_signed": true, but it did not help.

 

Config file:

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

    "certificates":{
        "validate": false,
	"allow_self_signed": true
    }
}

 

Error:

[FORCE] 2019-05-16 11:51:11,259 ./wsems: Initializing EMS ....
[FORCE] 2019-05-16 11:51:11,259 main: Using config file /home/pi/Desktop/microserver/etc/config.json
[INFO ] 2019-05-16 11:51:11,259 ./wsems: Creating the WsEms proxy.
[INFO ] 2019-05-16 11:51:11,259 ./wsems: Starting HTTP Server.
[WARN ] 2019-05-16 11:51:11,259 Main: Encryption is disabled on HTTP Server.
[WARN ] 2019-05-16 11:51:11,260 Main: Authentication is disabled on the HTTP Server.
[FORCE] 2019-05-16 11:51:11,260 httpServer: starting http server port=8080
[INFO ] 2019-05-16 11:51:11,260 ./wsems: Initializing the ThingWorx REST interface.
[INFO ] 2019-05-16 11:51:11,260 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2019-05-16 11:51:11,261 wsEmsProxy::initialize: Encryption is enabled on Web Socket connection.
[WARN ] 2019-05-16 12:51:11,262 SDK: SDK Version: 2.2.0
[WARN ] 2019-05-16 12:51:11,263 SDK: TLS Library: OpenSSL
[WARN ] 2019-05-16 12:51:11,263 SDK: TLS Library Version: 1.0.2l-fips
[WARN ] 2019-05-16 12:51:11,263 SDK: FIPS Capable
[INFO ] 2019-05-16 11:51:11,278 WsProxy::initialize: EMS Version 5.4.5.512
[INFO ] 2019-05-16 11:51:11,278 WsProxy::initialize: twApi singleton initialized
[WARN ] 2019-05-16 11:51:11,278 WsProxy::initialize: Certificate validation is disabled.
[WARN ] 2019-05-16 11:51:11,278 WsProxy::initialize: Self signed certificates are enabled.
[INFO ] 2019-05-16 11:51:11,280 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2019-05-16 11:51:11,282 ./wsems: Starting the connection.

10.128.54.64:8080-->[ERROR] 2019-05-16 12:51:11,288 SDK: TW_NEW_SSL_CLIENT: SSL handshake error. Error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.
[ERROR] 2019-05-16 12:51:11,289 SDK: Error intializing SSL connection
[ERROR] 2019-05-16 12:51:11,289 SDK: twWs_Connect: Error restarting socket.  Error 0

 

Any idea what could cause this? Also, if I don`t get it to work, is there another option to integrate the RPi in Thinworx?

 

Thank you!

 

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

 

augmentor
14-Alexandrite
(To:Rick-Stanley)

Thanks a lot, it worked perfectly!

 

I integrated the sensor values to the Hololens AR experience (video), and I was wondering if it theoretically would be possible to use finger gestures to start a laser attached to the Raspberry Pi for example? Would it be complicated?

 

 

augmentor
14-Alexandrite
(To:Rick-Stanley)

Thanks a lot, it worked perfectly!

 

I integrated the sensor values to the Hololens AR experience (video), and I was wondering if it theoretically would be possible to use finger gestures to start a laser attached to the Raspberry Pi for example? Would it be complicated?

 

 

Announcements


Top Tags