Skip to main content
1-Visitor
June 25, 2018
Question

Error implementing EMS on Raspberry Pi

  • June 25, 2018
  • 1 reply
  • 3074 views

I have a localhost Thingworx on my laptop;

http://localhost:8080/Thingworx

 

I setup a local EMS\LSR and successfully binded to my TestRemoteThing1 and updated the property.

 

Following the guide for "Connect Raspberry Pi to ThingWorx" in setup my Raspberry, installed and configured EMS\LSR and ran into the following issue:

Running the EMS with Auto Bind:

The Remote Monitor shows that my TestRemoteThing1 I green and ok.

 

"Error opening non-TLS socket [127.0.0.1:8001]"

"Error executing request on Things/TestRemoteThing1/Services/NotifyPropertyUpdate"

 

pi@raspberrypi:~/microserver $ sudo ./wsems
[FORCE] 2018-06-24 15:12:42,229 ./wsems: Initializing EMS ....
[FORCE] 2018-06-24 15:12:42,229 main: Using config file /home/pi/microserver/etc/config.json
[INFO ] 2018-06-24 15:12:42,229 ./wsems: Creating the WsEms proxy.
[INFO ] 2018-06-24 15:12:42,229 ./wsems: Starting HTTP Server.
[INFO ] 2018-06-24 15:12:42,229 Main: Using built-in certificate for HTTP Server
[WARN ] 2018-06-24 15:12:42,229 Main: Encryption is disabled on HTTP Server.
[WARN ] 2018-06-24 15:12:42,229 Main: Authentication is disabled on the HTTP Server.
[FORCE] 2018-06-24 15:12:42,229 httpServer: starting http server port=8000
[INFO ] 2018-06-24 15:12:42,229 ./wsems:
[INFO ] 2018-06-24 15:12:42,229 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2018-06-24 15:12:42,229 wsEmsProxy::initialize: Encryption is disabled on Web Socket connection.
[WARN ] 2018-06-24 15:12:42,230 SDK: SDK Version: 2.0.4
[WARN ] 2018-06-24 15:12:42,230 SDK: TLS Library: OpenSSL
[WARN ] 2018-06-24 15:12:42,230 SDK: TLS Library Version: 1.0.2l
[WARN ] 2018-06-24 15:12:42,230 SDK: FIPS Capable
[INFO ] 2018-06-24 15:12:42,278 WsProxy::initialize: EMS Version 5.4.0.114
[INFO ] 2018-06-24 15:12:42,278 WsProxy::initialize: twApi singleton initialized
[WARN ] 2018-06-24 15:12:42,278 WsProxy::initialize: Certificate validation is disabled.
[WARN ] 2018-06-24 15:12:42,278 WsProxy::initialize: Self signed certificates are enabled.
[ERROR] 2018-06-24 15:12:42,280 SDK: twMap_Add: parse function returned null.
[WARN ] 2018-06-24 15:12:42,281 WsEmsProxy::bindThing: Exception connecting to localhost:8001. Err: Connection refused [localhost:8001]
[WARN ] 2018-06-24 15:12:42,281 WsEmsProxy::bindThing: Changing host from 'localhost' to '127.0.0.1'
[INFO ] 2018-06-24 15:12:42,281 WsEmsProxy::registerVirtualDirs: Adding virtual dir logs: /home/pi/microserver/logs
[INFO ] 2018-06-24 15:12:42,282 WsEmsProxy::registerVirtualDirs: Adding virtual dir instruction: /home/pi/microserver/instruction
[INFO ] 2018-06-24 15:12:42,282 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2018-06-24 15:12:42,282 ./wsems: Starting the connection.

192.168.0.49:8080-->[INFO ] 2018-06-24 15:12:42,319 SDK: twWs_Connect: Websocket connected!
[WARN ] 2018-06-24 15:12:42,384 SDK: twBindBody_Delete: NULL body or stream pointer
[INFO ] 2018-06-24 15:12:42,433 Main: Succesfully connected. Saving .booted config file
[ERROR] 2018-06-24 15:12:43,457 UnencryptedClientStream::doopen: Error opening socket. Error: 111
[ERROR] 2018-06-24 15:12:43,457 HttpClient::initialize: Exception while opening connection request to 127.0.0.1. Error: Error opening non-TLS socket [127.0.0.1:8001]
[ERROR] 2018-06-24 15:12:43,458 emsRequestHandler: Error executing request on Things/TestRemoteThing1/Services/NotifyPropertyUpdate
[ERROR] 2018-06-24 15:12:53,93 UnencryptedClientStream::doopen: Error opening socket. Error: 111
[ERROR] 2018-06-24 15:12:53,93 HttpClient::initialize: Exception while opening connection request to 127.0.0.1. Error: Error opening non-TLS socket [127.0.0.1:8001]
[ERROR] 2018-06-24 15:12:53,93 emsRequestHandler: Error executing request on Things/TestRemoteThing1/Properties/TestProperty

 

My config.lua;

{
"ws_servers": [{
  "host": "192.168.0.49",
  "port": 8080
 }
],
"resource": "/Thingworx/WS",
"appKey": "c768f8f9-5501-4680-bebf-ed1bc86131ca",
"logger": {
 "level": "INFO",
 "publish_level": "INFO",
 "max_file_storage": 2000000,
 "publish_directory": "logs",
 "auto_flush": true,
 "flush_chunk_size": 16384,
 "buffer_size": 4096
},
"http_server": {
 "host": "localhost",
 "port": 8000,
 "ssl": false,
 "authenticate": false,
 "content_read_timeout": 20000,
 "ports_to_try": 10,
 "max_clients": 15,
 "use_default_certificate" : true
},
"fips": {
 "enabled": false
},
"ws_connection": {
 "encryption": "none",
 "verbose": false,
 "binary_mode": false,
 "msg_timeout": 5000,
 "ping_rate": 55000,
 "pingpong_timeout": 10000,
 "connect_period": 60000,
 "duty_cycle": 100,
 "message_idle_time": 50,
 "max_msg_size": 1048576,
 "message_chunk_size": 8192,
 "max_frame_size": 8192,
 "max_messages": 500,
 "connect_on_demand": false,
 "connect_timeout": 10000,
 "connect_retry_interval": 10000,
 "max_threads": 4,
 "max_connect_delay": 0,
 "socket_read_timeout": 100,
 "frame_read_timeout": 10000,
 "ssl_read_timeout": 500,
 "connect_retries": -1
},
"auto_bind":    [{
            "name": "TestRemoteThing1",
            "gateway":  false
    }],
"certificates": {
 "validate": false,
 "allow_self_signed": true
},
"file": {
  "virtual_dirs": [ 
   {"logs": "logs"},
   {"instruction":"instruction"}
  ],
  "staging_dir": "/home/pi/microserver/staging/staging"
}
}

 

I am stuck on this and really could use some help and ideas

Thanks

Dave

1 reply

5-Regular Member
June 25, 2018

The error message:

 

HttpClient::initialize: Exception while opening connection request to 127.0.0.1. Error: Error opening non-TLS socket [127.0.0.1:8001]

 

means the EMS is not able to connect to the LSR. Either LSR is not running, or it is listening on a different port. The config file you included looks like config.json which is used to configure the EMS. Please share your config.lua file. 

iotbuck1-VisitorAuthor
1-Visitor
June 25, 2018

Moving forward I made some changes to the ports

I am no longer getting errors in EMS or LSR, but I am getting Application errors in Thingworx

 

Error reading property [thing: TestRemoteThing1, property: TestProperty] Timed out APIRequestMessage [requestId: 340, endpointId: -1, sessionId: -1, method: GET, entityName: TestRemoteThing1, characteristic: Properties, target: TestProperty]

 

config.json:

{

"ws_servers": [{
"host": "192.168.0.49",
"port": 8080
}
],

"resource": "/Thingworx/WS",

"appKey": "c768f8f9-5501-4680-bebf-ed1bc86131ca",
"logger": {
"level": "INFO",
"publish_level": "INFO",
"max_file_storage": 2000000,
"publish_directory": "logs",
"auto_flush": true,
"flush_chunk_size": 16384,
"buffer_size": 4096
},

"http_server": {
"host": "localhost",
"port": 8000,
"ssl": false,
"authenticate": false,
"content_read_timeout": 20000,
"ports_to_try": 10,
"max_clients": 15,
"use_default_certificate" : true
},

"fips": {
"enabled": false
},

"ws_connection": {
"encryption": "none",
"verbose": false,
"binary_mode": false,
"msg_timeout": 5000,
"ping_rate": 55000,
"pingpong_timeout": 10000,
"connect_period": 60000,
"duty_cycle": 100,
"message_idle_time": 50,
"max_msg_size": 1048576,
"message_chunk_size": 8192,
"max_frame_size": 8192,
"max_messages": 500,
"connect_on_demand": false,
"connect_timeout": 10000,
"connect_retry_interval": 10000,
"max_threads": 4,
"max_connect_delay": 0,
"socket_read_timeout": 100,
"frame_read_timeout": 10000,
"ssl_read_timeout": 500,
"connect_retries": -1
},
"certificates": {
"validate": false,
"allow_self_signed": true
},
"file": {
"virtual_dirs": [
{"logs": "logs"},
{"instruction":"instruction"}
],
"staging_dir": "/home/pi/microserver/staging/staging"
}

}

 

config.lua


scripts.rap_host = "127.0.0.1"
scripts.rap_port = 8000
scripts.rap_ssl = false
scripts.rap_server_authenticate = false
scripts.script_resource_host = "127.0.0.1"
scripts.script_resource_port = 8001
scripts.script_resource_ssl = false
scripts.script_resource_authenticate = false

scripts["TestRemoteThing1"] = {
    file = "thing.lua",
    template = "TestRemoteThing1",
    scanRate = 10000
}
 
EMS Log:
pi@raspberrypi:~/microserver $ sudo ./wsems
[FORCE] 2018-06-25 15:16:42,464 ./wsems: Initializing EMS ....
[FORCE] 2018-06-25 15:16:42,464 main: Using config file /home/pi/microserver/etc/config.json
[INFO ] 2018-06-25 15:16:42,464 ./wsems: Creating the WsEms proxy.
[INFO ] 2018-06-25 15:16:42,464 ./wsems: Starting HTTP Server.
[INFO ] 2018-06-25 15:16:42,465 Main: Using built-in certificate for HTTP Server
[WARN ] 2018-06-25 15:16:42,465 Main: Encryption is disabled on HTTP Server.
[WARN ] 2018-06-25 15:16:42,465 Main: Authentication is disabled on the HTTP Server.
[FORCE] 2018-06-25 15:16:42,465 httpServer: starting http server port=8000
[INFO ] 2018-06-25 15:16:42,466 ./wsems: Initializing the ThingWorx REST interface.
[INFO ] 2018-06-25 15:16:42,466 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2018-06-25 15:16:42,466 wsEmsProxy::initialize: Encryption is disabled on Web Socket connection.
[WARN ] 2018-06-25 15:16:42,468 SDK: SDK Version: 2.0.4
[WARN ] 2018-06-25 15:16:42,468 SDK: TLS Library: OpenSSL
[WARN ] 2018-06-25 15:16:42,468 SDK: TLS Library Version: 1.0.2l
[WARN ] 2018-06-25 15:16:42,468 SDK: FIPS Capable
[INFO ] 2018-06-25 15:16:42,485 WsProxy::initialize: EMS Version 5.4.0.114
[INFO ] 2018-06-25 15:16:42,486 WsProxy::initialize: twApi singleton initialized
[WARN ] 2018-06-25 15:16:42,486 WsProxy::initialize: Certificate validation is disabled.
[WARN ] 2018-06-25 15:16:42,486 WsProxy::initialize: Self signed certificates are enabled.
[ERROR] 2018-06-25 15:16:42,488 SDK: twMap_Add: parse function returned null.
[INFO ] 2018-06-25 15:16:42,487 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2018-06-25 15:16:42,489 ./wsems: Starting the connection.
192.168.0.49:8080-->[INFO ] 2018-06-25 15:16:42,521 SDK: twWs_Connect: Websocket connected!
[INFO ] 2018-06-25 15:16:42,590 Main: Succesfully connected.  Saving .booted config file
 
LSR log:
pi@raspberrypi:~/microserver $ sudo ./luaScriptResource
[INFO ] 2018-06-25 15:17:00,932 ./luaScriptResource: Using config file: /home/pi/microserver/etc/config.lua
[FORCE] 2018-06-25 15:17:00,932 ./luaScriptResource: Starting up ....
[INFO ] 2018-06-25 15:17:00,938 luaScriptResource:main: Encryption is disabled on the RAP connection.
[INFO ] 2018-06-25 15:17:00,938 luaScriptResource:main: FIPS is disabled.
[INFO ] 2018-06-25 15:17:00,939 ./luaScriptResource: New path is /home/pi/microserver/etc/thingworx/clibs:/home/pi/microserver/etc/custom/clibs:/home/pi/microserver/etc/community/clibs:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[WARN ] 2018-06-25 15:17:00,940 ScriptResource::initialize: Encryption is disabled on HTTP Server.
[WARN ] 2018-06-25 15:17:00,940 ScriptResource::initialize: Authentication is disabled on the HTTP Server.
[INFO ] 2018-06-25 15:17:00,967 sample: Registering HTTP callbacks
[FORCE] 2018-06-25 15:17:00,981 httpServer: starting http server port=8001
[INFO ] 2018-06-25 15:17:00,981 sample: Beginning main loop
[INFO ] 2018-06-25 15:17:01,6 thingworx.shape: Creating a new shape.
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: -- Configuration -------------------------------
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: scanRate: 10000
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: scanRateResolution: 500
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: taskRate: 15000
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: keepAliveRate: 60000
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: requestTimeout: 15000
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: registerRate: 43200000
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: register: true
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: getPropertySubscriptionOnReconnect: false
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: maxConcurrentPropertyUpdates: 100
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: defaultPushType: VALUE
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: useShapes: true
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: identifier: Not Specififed
[INFO ] 2018-06-25 15:17:01,7 TestRemoteThing1: ------------------------------------------------
[INFO ] 2018-06-25 15:17:01,9 thingworx.template: Adding shape 'shapes.metadata' to template 'thingworx.template'
[INFO ] 2018-06-25 15:17:01,9 thingworx.template: Adding shape 'shapes.propsubscribe' to template 'thingworx.template'
[INFO ] 2018-06-25 15:17:01,10 TestRemoteThing1: Calling TestProperty Handler Property Functions
[INFO ] 2018-06-25 15:17:01,10 thingworx.template: Creating new templates.TestRemoteThing1 named 'TestRemoteThing1'
[INFO ] 2018-06-25 15:17:01,10 TestRemoteThing1: -- Initializing properties ---------------------
[INFO ] 2018-06-25 15:17:01,10 TestRemoteThing1: Initialized property upToDate [baseType: BOOLEAN, pushType: NEVER, handler: nil, value: true]
[INFO ] 2018-06-25 15:17:01,10 TestRemoteThing1: Initialized property TestProperty [baseType: NUMBER, pushType: NEVER, handler: nil, value: 888]
[INFO ] 2018-06-25 15:17:01,10 TestRemoteThing1: ------------------------------------------------
[INFO ] 2018-06-25 15:17:02,980 TestRemoteThing1: -- Starting script --------------------------
[INFO ] 2018-06-25 15:17:02,980 TestRemoteThing1: Registering core callback handler
[INFO ] 2018-06-25 15:17:02,981 TestRemoteThing1: Starting main loop
[INFO ] 2018-06-25 15:17:02,981 TestRemoteThing1: Calling lifecycle start listeners.
[INFO ] 2018-06-25 15:17:02,981 shapes.propsubscribe: Initialized
 
Thanks
Dave
 
5-Regular Member
June 25, 2018

Do you have a file \etc\custom\templates\TestRemoteThing1.lua that is referenced in config.lua