Skip to main content
1-Visitor
March 4, 2018
Question

Error connecting raspberry pi using ssl

  • March 4, 2018
  • 2 replies
  • 9594 views

Trying to connect Raspberry Pi to ThingWorx using the Edge MicroServer (EMS). Getting issue while binding the remote thing properties. Please guide to fix the issue. Something need to check  

 

OS: Windows 10

Apache Tomcat : Apache Tomcat 8.5.13 Server  (Java: Java\jre1.8.0_161)
Thingworx Platform: MED-61182-CD-080_SP7_ThingWorx-Platform-H2-8-0-7
 
Raspberry Pi - Linux raspberrypi 4.9.59-v7, armv7l architecture
EMS (v5.4.0) and LSR hosted same
 
Both systems are in same network. EMS - http server on the default port (localhost:8000). Lua script default port (localhost:8001).
 

Launched EMS sucessfully.

Configured the LSR & able to execute it (Logs: $ sudo ./luaScriptResource)

[FORCE] 2018-03-03 09:49:28,242 httpServer: starting http server port=8001
[INFO ] 2018-03-03 09:49:28,263 thingworx.shape: Creating a new shape.
[INFO ] 2018-03-03 09:49:28,264 PiThing: -- Configuration -------------------------------
[INFO ] 2018-03-03 09:49:28,265 PiThing: scanRate: 1000
[INFO ] 2018-03-03 09:49:28,265 PiThing: scanRateResolution: 500
[INFO ] 2018-03-03 09:49:28,265 PiThing: taskRate: 30000
[INFO ] 2018-03-03 09:49:28,265 PiThing: keepAliveRate: 60000
[INFO ] 2018-03-03 09:49:28,265 PiThing: requestTimeout: 15000
[INFO ] 2018-03-03 09:49:28,265 PiThing: registerRate: 43200000
[INFO ] 2018-03-03 09:49:28,266 PiThing: register: true
[INFO ] 2018-03-03 09:49:28,266 PiThing: getPropertySubscriptionOnReconnect: false
[INFO ] 2018-03-03 09:49:28,266 PiThing: maxConcurrentPropertyUpdates: 100
[INFO ] 2018-03-03 09:49:28,266 PiThing: defaultPushType: VALUE
[INFO ] 2018-03-03 09:49:28,266 PiThing: useShapes: true
[INFO ] 2018-03-03 09:49:28,266 PiThing: identifier: PiThing
[INFO ] 2018-03-03 09:49:28,266 PiThing: ------------------------------------------------
[INFO ] 2018-03-03 09:49:28,267 thingworx.template: Adding shape 'shapes.metadata' to template 'thingworx.template'
[INFO ] 2018-03-03 09:49:28,267 thingworx.template: Adding shape 'shapes.propsubscribe' to template 'thingworx.template'
[INFO ] 2018-03-03 09:49:28,268 thingworx.template: Creating new templates.PiTemplate named 'PiThing'
[INFO ] 2018-03-03 09:49:28,268 PiThing: -- Initializing properties ---------------------
[INFO ] 2018-03-03 09:49:28,268 PiThing: Initialized property upToDate [baseType: BOOLEAN, pushType: NEVER, handler: nil, value: true]
[INFO ] 2018-03-03 09:49:28,268 PiThing: Initialized property cpu_volt [baseType: NUMBER, pushType: VALUE, handler: nil, value: 0]
[INFO ] 2018-03-03 09:49:28,269 PiThing: Initialized property cpu_temperature [baseType: NUMBER, pushType: VALUE, handler: nil, value: 0]
[INFO ] 2018-03-03 09:49:28,269 PiThing: Initialized property cpu_freq [baseType: NUMBER, pushType: VALUE, handler: nil, value: 0]
[INFO ] 2018-03-03 09:49:28,269 PiThing: ------------------------------------------------
[INFO ] 2018-03-03 09:49:28,269 Thingworx: Registering identifier *PiThing for thing PiThing
[INFO ] 2018-03-03 09:49:29,270 PiThing: Identifier *PiThing registered with main Thingworx script for for Thing PiThing
[INFO ] 2018-03-03 09:49:31,240 PiThing: -- Starting script --------------------------
[INFO ] 2018-03-03 09:49:31,240 PiThing: Registering core callback handler
[INFO ] 2018-03-03 09:49:31,240 PiThing: Starting main loop
[INFO ] 2018-03-03 09:49:31,240 PiThing: Calling lifecycle start listeners.
[INFO ] 2018-03-03 09:49:31,241 shapes.propsubscribe: Initialized
[INFO ] 2018-03-03 09:49:31,242 thingworx.handler: Creating a new handler.

as per mentioned here

 

Tested WS EMS online with following commands (on EMS - raspberry pi)

Remote Thing property is connected.

pi@raspberrypi:~ $ curl http://localhost:8000/Thingworx/Things/LocalEms/Properties/isConnected

{"rows":[{"isConnected":true}],"datashape":{"fieldDefinitions":{"isConnected":{"name":"isConnected","description":"","baseType":"BOOLEAN","aspects":{}}}}}

pi@raspberrypi:~ $ curl http://localhost:8000/Thingworx/Things/SystemRepository/Properties/name
{"rows":[{"name":"SystemRepository"}],"datashape":{"fieldDefinitions":{"name":{"name":"name","description":"","baseType":"STRING","aspects":{}}}}}

 

Scripts is also running

pi@raspberrypi:~ $ curl http://localhost:8001/scripts
2 scripts installed

Name Status Result File 
PiThing Running /home/pi/microserver/etc/ 
Thingworx Running /home/pi/microserver/etc/ 

 

Issue: Not able to Bind the remote Thing properties. (here > 5. Bind the remote Thing properties.)

 

Remote Thing(PiThing) > Manage Bindings > 'remote' section - available properties not listed, giving error "Error browsing properties. Be sure the remote device/server is connected and configured properly".

 

 

 

 
 
 

2 replies

5-Regular Member
March 5, 2018

Hi @snehalpatil could you configure the WS EMS logging to Trace and reproduce the issue with the SSL connectivity and attach the log here?

 

It will also help to see the config.json from WS EMS and lua.config from LSR configuration with SSL configuration. Have you tested the auto_bind configuration with Gateway in WS EMS's config.json file in SSL configuration to see if that still throws the same error?

1-Visitor
March 5, 2018

 

Thank you   supandey
,
 
 

 

Thingworx - http://192.168.1.22:443/Thingworx/Composer/index.html)

 

Please find the WS EMS logs (ws-ems-log.txt)

 

microserver/etc/config.json

 

{
"ws_servers": [{
 "host": "192.168.1.22",
 "port": 443
 }],
 "resource": "/Thingworx/WS",
 "appKey": "*********************",
 "http_server": {
 "host": "localhost",
 "port": 8000,
 "ssl" : false,
 "authenticate" : false
 },
 "logger": {
 "level": "DEBUG"
 },
 "auto_bind": [{
 "name": "PiThing",
 "gateway": false,
 "host": "localhost"
 }],
 "certificates": {
 "validate": false,
 "allow_self_signed": false 
 } ,
 "ws_connection": {
 "encryption": "none",
 "verbose": true,
 "msg_timeout": 1000
 }
}

microserver/etc/config.lua

 

scripts.log_level = "INFO"
scripts.PiThing = {
 file = "thing.lua",
 template = "PiTemplate",
 identifier = "PiThing",
 scanRate = 1000,
 taskRate = 30000
}

scripts.script_resource_ssl = false
scripts.script_resource_authenticate = false

scripts.rap_host = "localhost"
scripts.rap_port = "8000" 

scripts.script_resource_host = "localhost"
scripts.script_resource_ssl = "false"
scripts.script_resource_port = "8001"

Trying to connect Raspberry Pi to ThingWorx using the Edge MicroServer (EMS). Getting issue while binding the remote thing properties. Tried without ssl.

1-Visitor
March 7, 2018

Please guide to find the cause of issue & way to fix it? Will be helpful to process further.

Checked with https & http connectivity between WS EMS & Thingworx ( https://192.168.1.22/Thingworx/Composer/index.html )

 

While debuging issue today, getting following error

 

$ sudo ./wsems 
[FORCE] 2018-03-07 13:11:13,151 ./wsems: Initializing EMS ....
[FORCE] 2018-03-07 13:11:13,151 main: Using config file /home/pi/microserver/etc/config.json
[FORCE] 2018-03-07 13:11:13,152 httpServer: starting http server port=8000
[ERROR] 2018-03-07 18:41:13,169 SDK: twMap_Add: parse function returned null.

192.168.1.28:443-->[ERROR] 2018-03-07 13:11:14,317 UnencryptedClientStream::doopen: Error opening socket. Error: 111
[ERROR] 2018-03-07 13:11:14,318 HttpClient::initialize: Exception while opening connection request to 127.0.0.1. Error: Error opening non-TLS socket [127.0.0.1:8002]
[ERROR] 2018-03-07 13:11:14,318 emsRequestHandler: Error executing request on Things/PiThing/Services/NotifyPropertyUpdate




Is above related to permission issue while connecting EMS to Thingworx? In microserver/etc/config.json configuration used Appkey with user have Administrator rights. Something more need to check for above?Please guide.

12-Amethyst
March 13, 2018

Hi @snehalpatil,

 

I think the problem here is you're auto-binding with the same thingname as you're trying to use on the Lua ScriptResource - PiThing.  Try removing the 'auto-bind' settings from config.json and you should be able to browse the remote properties in composer

1-Visitor
July 4, 2018

I had the same issue.

In order to see the remote thing in the identifier list when creating the thing on the Thingworx cloud, you simply have to add an asterisk before your thing name in the auto binding section of your config.json configuration file :

"auto_bind": [{
 "name": "*PiThing",...