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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Error connecting Raspberry EMS to Thingworx Composer

OscarD
1-Newbie

Error connecting Raspberry EMS to Thingworx Composer

Hi,

I just installed the EMS on my Raspberry Pi, following the steps in https://developer.thingworx.com/resources/guides/thingworx-raspberry-pi-quickstart/launch-ems I created a config.json file in order to bind it to my Thingworx composer running on another computer in my local network but I have some issues.

Hi I am having the following errors in debug:

[INFO ] 2017-10-30 20:41:46,44 ./wsems: Using config file: /home/pi/Desktop/microserver/etc/config.json

[FORCE] 2017-10-30 20:41:46,45 ./wsems: Starting up ....

[FORCE] 2017-10-30 20:41:46,46 ./wsems: Initializing EMS ....

[FORCE] 2017-10-30 20:41:46,46 main: Using config file /home/pi/Desktop/microserver/etc/config.json

[INFO ] 2017-10-30 20:41:46,46 ./wsems: Creating the WsEms proxy.

[INFO ] 2017-10-30 20:41:46,46 ./wsems: Starting HTTP Server.

[INFO ] 2017-10-30 20:41:46,46 ./wsems: Initializing the ThingWorx REST interface.

[FORCE] 2017-10-30 20:41:46,46 httpServer:

[DEBUG] 2017-10-30 20:41:46,47 httpServer: http server bound to port=8080.

[DEBUG] 2017-10-30 20:41:46,48 SDK: twWs_Create: Initializing Websocket Client for 192.168.15.166:8080/Thingworx

[DEBUG] 2017-10-30 20:41:46,48 SDK: twTlsClient_Create: Initializing TLS Client

[DEBUG] 2017-10-30 20:41:46,49 SDK: twApi_Initialize: Websocket Established after 0 tries

[DEBUG] 2017-10-30 20:41:46,49 SDK: subscribedPropsMgr_Initialize: Initializing subscribed properties manager

[DEBUG] 2017-10-30 20:41:46,49 jsonConfigurator::getJsonEntity: Key cert_chain not found

[DEBUG] 2017-10-30 20:41:46,49 jsonConfigurator::getJsonEntity: Key validation_criteria not found

[DEBUG] 2017-10-30 20:41:46,49 jsonConfigurator::getJsonEntity: Parent file not found

[DEBUG] 2017-10-30 20:41:46,50 SDK: twTunnelManager_Create: Tunnel Manager singleton already exists

[DEBUG] 2017-10-30 20:41:46,50 WsEmsProxy::bindThing: Host specified as 'localhost'.  Testing IPV6/IPV4 connectivity

[WARN ] 2017-10-30 20:41:46,53 WsEmsProxy::bindThing: Exception connecting to localhost:8001.  Err: Connection refused [localhost:8001]

[WARN ] 2017-10-30 20:41:46,53 WsEmsProxy::bindThing: Changing host from 'localhost' to '127.0.0.1'

[DEBUG] 2017-10-30 20:41:46,54 SDK: added PiThing to boundList

[DEBUG] 2017-10-30 20:41:46,54 SDK: twApi_BindThings: not currently connected, only binding things to api

[DEBUG] 2017-10-30 20:41:46,54 SDK: twMessage_Delete:  Deleting BIND Message: 1

[DEBUG] 2017-10-30 20:41:46,54 jsonConfigurator::getJsonEntity: Parent file not found

[INFO ] 2017-10-30 20:41:46,54 wsEmsProxy::initialize: Initialization complete!

[INFO ] 2017-10-30 20:41:46,55 ./wsems: Starting the connection.

192.168.15.166:8080-->[DEBUG] 2017-10-30 20:41:46,57 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:41:46,58 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:41:46,266 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:41:51,267 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:41:51,267 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:41:51,477 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:41:56,477 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:41:56,477 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:41:56,706 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:01,707 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:01,707 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:01,927 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:06,927 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:06,927 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:07,157 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:12,157 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:12,157 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:12,372 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:17,372 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:17,373 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:17,586 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:22,587 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:22,587 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:22,807 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:27,807 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:27,808 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:28,26 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:33,27 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:33,27 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:33,255 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:38,255 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:38,256 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:38,487 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[DEBUG] 2017-10-30 20:42:43,487 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-10-30 20:42:43,488 SDK: twTlsClient_Connect: Connecting to server

[ERROR] 2017-10-30 20:42:43,703 SDK: twWs_Connect: Error initializing web socket.  Response code: 400

[WARN ] 2017-10-30 20:42:46,103 Main: Unable to connect to server.  Trying .booted config file

[WARN ] 2017-10-30 20:42:48,702 WsEmsProxy::execute() : Server connection failed.  Error Code: 201

[FORCE] 2017-10-30 20:42:51,205 Main: Shutdown signal received. Restarting ....

[DEBUG] 2017-10-30 20:42:51,206 SDK: twMessage_Send: Not authenticated yet

[ERROR] 2017-10-30 20:42:51,206 SDK: twMessage_Send: Error sending Message with RequestId 2

[ERROR] 2017-10-30 20:42:51,206 SDK: twApi_UnbindThing: Error creating sending Unbind message

[DEBUG] 2017-10-30 20:42:51,206 SDK: twMessage_Delete:  Deleting BIND Message: 2

terminate called without an active exception

My config.json file is:

{

    "ws_servers":   [{

            "host": "192.168.15.166",

            "port": 8080

        }],

    "resource": "Thingworx",

    "http_server":  {

        "host": "127.0.0.1",

        "port": 8080

    },

    "appKey":   "78e807c4-a1c0-458d-ace5-c465e16f3efb",

    "logger":   {

        "level":    "DEBUG"

    },

    "auto_bind":    [{

            "name": "PiThing",

            "gateway":  false

        }],

    "certificates": {

        "validate": false,

        "allow_self_signed":    true

    },

    "ws_connection":    {

        "encryption":   "none",

        "verbose":  true,

        "msg_timeout":  1000

    }

}

When I access my TW composer "ws_servers" on "192.168.15.166:8080/Thingworx", I login with an user and a password, Do I have to put these credentials somewhere in the config.json file? This could be the cause why the binding is not possible or has nothing to do?


Thanks!

ACCEPTED SOLUTION

Accepted Solutions
alex.augot
5-Regular Member
(To:OscarD)

Hi Oscar,

I think the issue is you have an incorrect 'Resource' value in config.json.  You're pointing to 'Thingworx' rather than '/Thingworx/WS' which is the endpoint for a websocket connection.  The platform is correctly returning 400 (Bad Request) since it doesn't understand the request the EMS is sending it.  Take a look at config.json.complete in your EMS's etc directory for examples of default values.

View solution in original post

4 REPLIES 4
OscarD
1-Newbie
(To:OscarD)

Hi team, any ideas about this issue?

The http_server refers to the server that the EMS starts running so that other processes like the Lua script resource can connect to it.  If you are connecting to a ThingWorx foundation instance using port 8080 then you must pick a different port for the EMS server and enter that port number in http_server. It does not matter what port you pick, however if you use Lua Script Resource you must configure it to use the same port

Here is a good explanation

Using the Edge MicroServer and LSR in a Gateway Scenario

alex.augot
5-Regular Member
(To:OscarD)

Hi Oscar,

I think the issue is you have an incorrect 'Resource' value in config.json.  You're pointing to 'Thingworx' rather than '/Thingworx/WS' which is the endpoint for a websocket connection.  The platform is correctly returning 400 (Bad Request) since it doesn't understand the request the EMS is sending it.  Take a look at config.json.complete in your EMS's etc directory for examples of default values.

Hi Alex

Thank you for your answer, it solved the issue .

Announcements

Top Tags