1 Reply Latest reply on Jan 8, 2018 1:36 PM by jgrandasfranco RSS
    jgrandasfranco Newbie

    Error trying to connect ThingWorx to the raspberry pi.

    Hi. I joined this community just a few weeks ago because i'm currently working on a project among which basically consist on transfering some kind of information to a clud using a Raspberry pi device.

     

    I'm currently dealing with the Quickstart tutorial, but i'm having next problems while trying to validate that my EMS has been succesfully connected:

     

    [INFO ] 2017-12-20 18:42:56,583 ./wsems: Using config file: /home/pi/microserver/etc/config.json

    [FORCE] 2017-12-20 18:42:56,583 ./wsems: Starting up ....

    [FORCE] 2017-12-20 18:42:56,584 ./wsems: Initializing EMS ....

    [FORCE] 2017-12-20 18:42:56,584 main: Using config file /home/pi/microserver/etc/config.json

    [INFO ] 2017-12-20 18:42:56,584 ./wsems: Creating the WsEms proxy.

    [INFO ] 2017-12-20 18:42:56,584 ./wsems: Starting HTTP Server.

    [INFO ] 2017-12-20 18:42:56,585 ./wsems: Initializing the ThingWorx REST interface.

    [FORCE] 2017-12-20 18:42:56,585 httpServer: starting http server port=8080

    [DEBUG] 2017-12-20 18:42:56,585 httpServer: http server bound to port=8080.

    [DEBUG] 2017-12-20 18:42:56,587 SDK: twWs_Create: Initializing Websocket Client for 10.0.75.1:80//Thingworx/WS

    [DEBUG] 2017-12-20 18:42:56,587 SDK: twTlsClient_Create: Initializing TLS Client

    [DEBUG] 2017-12-20 18:42:56,587 SDK: twApi_Initialize: Websocket Established after 0 tries

    [DEBUG] 2017-12-20 18:42:56,587 SDK: subscribedPropsMgr_Initialize: Initializing subscribed properties manager

    [DEBUG] 2017-12-20 18:42:56,587 jsonConfigurator::getJsonEntity: Key cert_chain not found

    [DEBUG] 2017-12-20 18:42:56,587 jsonConfigurator::getJsonEntity: Key validation_criteria not found

    [DEBUG] 2017-12-20 18:42:56,588 jsonConfigurator::getJsonEntity: Parent file not found

    [DEBUG] 2017-12-20 18:42:56,589 SDK: twTunnelManager_Create: Tunnel Manager singleton already exists

    [DEBUG] 2017-12-20 18:42:56,588 WsEmsProxy::bindThing: Host specified as 'localhost'.  Testing IPV6/IPV4 connectivity

    [WARN ] 2017-12-20 18:42:56,599 WsEmsProxy::bindThing: Exception connecting to localhost:8001.  Err: Connection refused [localhost:8001]

    [WARN ] 2017-12-20 18:42:56,599 WsEmsProxy::bindThing: Changing host from 'localhost' to '127.0.0.1'

    [DEBUG] 2017-12-20 18:42:56,600 SDK: added PiThing to boundList

    [DEBUG] 2017-12-20 18:42:56,600 SDK: twApi_BindThings: not currently connected, only binding things to api

    [DEBUG] 2017-12-20 18:42:56,600 SDK: twMessage_Delete:  Deleting BIND Message: 1

    [DEBUG] 2017-12-20 18:42:56,600 jsonConfigurator::getJsonEntity: Parent file not found

    [INFO ] 2017-12-20 18:42:56,600 wsEmsProxy::initialize: Initialization complete!

    [INFO ] 2017-12-20 18:42:56,601 ./wsems: Starting the connection.

     

     

    10.0.75.1:80-->[DEBUG] 2017-12-20 18:42:56,604 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:42:56,604 SDK: twTlsClient_Connect: Connecting to server

    [ERROR] 2017-12-20 18:42:59,749 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:42:59,749 SDK: twWs_Connect: Error restarting socket.  Error 113

    [DEBUG] 2017-12-20 18:43:04,749 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:43:04,749 SDK: twTlsClient_Connect: Connecting to server

    [ERROR] 2017-12-20 18:43:07,909 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:43:07,909 SDK: twWs_Connect: Error restarting socket.  Error 113

    [DEBUG] 2017-12-20 18:43:12,909 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:43:12,909 SDK: twTlsClient_Connect: Connecting to server

    [ERROR] 2017-12-20 18:43:16,69 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:43:16,69 SDK: twWs_Connect: Error restarting socket.  Error 113

    [DEBUG] 2017-12-20 18:43:21,69 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:43:21,69 SDK: twTlsClient_Connect: Connecting to server

    [ERROR] 2017-12-20 18:43:24,229 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:43:24,229 SDK: twWs_Connect: Error restarting socket.  Error 113

    [DEBUG] 2017-12-20 18:43:29,229 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:43:29,229 SDK: twTlsClient_Connect: Connecting to server

    [ERROR] 2017-12-20 18:43:32,389 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:43:32,389 SDK: twWs_Connect: Error restarting socket.  Error 113

    [DEBUG] 2017-12-20 18:43:37,389 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:43:37,389 SDK: twTlsClient_Connect: Connecting to server

    [ERROR] 2017-12-20 18:43:40,549 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:43:40,549 SDK: twWs_Connect: Error restarting socket.  Error 113

    [DEBUG] 2017-12-20 18:43:45,549 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:43:45,549 SDK: twTlsClient_Connect: Connecting to server

    [ERROR] 2017-12-20 18:43:48,709 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:43:48,709 SDK: twWs_Connect: Error restarting socket.  Error 113

    [DEBUG] 2017-12-20 18:43:53,709 SDK: twTlsClient_Reconnect: Re-establishing SSL context

    [DEBUG] 2017-12-20 18:43:53,709 SDK: twTlsClient_Connect: Connecting to server

    [WARN ] 2017-12-20 18:43:56,609 Main: Unable to connect to server.  Trying .booted config file

    [ERROR] 2017-12-20 18:43:56,868 SDK: Error intializing socket connection.  Err = 113

    [ERROR] 2017-12-20 18:43:56,869 SDK: twWs_Connect: Error restarting socket.  Error 113

    [WARN ] 2017-12-20 18:44:01,868 WsEmsProxy::execute() : Server connection failed.  Error Code: 1001

    [FORCE] 2017-12-20 18:44:06,679 Main: Shutdown signal received. Restarting ....

    [DEBUG] 2017-12-20 18:44:06,680 SDK: twMessage_Send: Not authenticated yet

    [ERROR] 2017-12-20 18:44:06,680 SDK: twMessage_Send: Error sending Message with RequestId 2

    [ERROR] 2017-12-20 18:44:06,680 SDK: twApi_UnbindThing: Error creating sending Unbind message

    [DEBUG] 2017-12-20 18:44:06,680 SDK: twMessage_Delete:  Deleting BIND Message: 2

    terminate called without an active exception

     

     

     

     

    My jason.file is looking as follows:

     

    {

        "ws_servers":   [{

                "host": "10.0.75.1",

                "port": 80

            }],

        "http_server":  {

            "host": "127.0.0.1",

            "port": 8080

        },

        "appKey":   "cb983f51-0072-4945-ab9a-e2856a122c39",

        "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

        }

    }

     

    Could somebody help me please?, becase I need to go through this step in order to continue with the tutorial.

      • Re: Error trying to connect ThingWorx to the raspberry pi.
        stevegr Creator

        This thread might help

        https://community.thingworx.com/thread/40338?q=ems%20l


        I have found it pretty easy to use the SDK directly using a Raspberry PI and a Wifi adapter connected and running localThingworx server - this reduces problems with networks, certificates etc. so you can focus on the connection.

        In the past I have set a PI and used the SDK to deploy the EMS code and used my phone as a hotspot so the Thingworx server and PI can connect to the same network over the same wifi. Once you have that then you can find out the ip for the server and set that to the correct values in your main.c.

        Alternatively if the Server is hosted you will have get its ip address and plug that into you EMS settings. Hopefully the server is not using certificates and port 80 is open.

         

        example of code in the main.c 

         

        #define TW_HOST "192.168.43.154"

        #define TW_APP_KEY "ce22e9e4-2834-419c-9656-ef9f844c784c"

         

         

        #if defined NO_TLS

        int16_t port = 80;

        #else

        int16_t port = 8443;

        #endif