Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
I am trying to follow the guide in the connect section of the thing work. developer to connect the raspberry pi,
while setting up the EMS and executing it, I get the following error
pi@raspberrypi:~/Desktop/microserver $ ./wsems
[FORCE] 2020-04-17 09:20:04,121 ./wsems: Initializing EMS ....
[FORCE] 2020-04-17 09:20:04,121 main: Using config file /home/pi/Desktop/microserver/etc/config.json
[INFO ] 2020-04-17 09:20:04,121 ./wsems: Creating the WsEms proxy.
[INFO ] 2020-04-17 09:20:04,122 ./wsems: Starting HTTP Server.
[WARN ] 2020-04-17 09:20:04,122 Main: Encryption is disabled on HTTP Server.
[WARN ] 2020-04-17 09:20:04,122 Main: Authentication is disabled on the HTTP Server.
[INFO ] 2020-04-17 09:20:04,122 ./wsems: Initializing the ThingWorx REST interface.
[FORCE] 2020-04-17 09:20:04,122 httpServer: Initializing the ThingWorx8080
[INFO ] 2020-04-17 09:20:04,123 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2020-04-17 09:20:04,123 wsEmsProxy::initialize: Encryption is enabled on Web Socket connection.
[WARN ] 2020-04-17 14:50:04,124 SDK: SDK Version: 2.2.0
[WARN ] 2020-04-17 14:50:04,125 SDK: TLS Library: OpenSSL
[WARN ] 2020-04-17 14:50:04,125 SDK: TLS Library Version: 1.0.2l-fips
[WARN ] 2020-04-17 14:50:04,125 SDK: FIPS Capable
[ERROR] 2020-04-17 14:50:04,244 SDK: twStream_CreateFromFile: error opening file: /opt/thingworx/subscribed_properties.bin
[ERROR] 2020-04-17 14:50:04,244 SDK: subscribedPropsMgr_Initialize: Error opening: /opt/thingworx/subscribed_properties.bin
[INFO ] 2020-04-17 09:20:04,244 WsProxy::initialize: EMS Version 5.4.5.512
[INFO ] 2020-04-17 09:20:04,244 WsProxy::initialize: twApi singleton initialized
[WARN ] 2020-04-17 09:20:04,244 WsProxy::initialize: Certificate validation is disabled.
[INFO ] 2020-04-17 09:20:04,245 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2020-04-17 09:20:04,247 ./wsems: Starting the connection.
pp-19022819274p.portal.ptc.io:443-->[ERROR] 2020-04-17 14:50:15,118 SDK: twWs_Connect: Timed out trying to connect
[ERROR] 2020-04-17 14:50:24,363 SDK: twWs_Connect: Error initializing web socket. Response code: 502
I am using this config.json
{
"ws_servers": [{
"host": "pp-19022819274p.portal.ptc.io",
"port": 443
}],
"appKey": "4e84018a-03e2-49ff-884d-e65d7067d80f",
"http_server" : {
"host": "127.0.0.1",
"port": 8080,
"use_default_certificate" : true,
"ssl" : false,
"authenticate" : false
},
"logger":{
"level":"INFO"
},
"certificates":{
"validate": false
}
}
Your Developer Portal trial server is not running.
The trial servers provided by the Developer Portal will automatically shut down after 3 hours of no browsing activity in any Developer Portal guides. Log into your account hosted trial info page and click the green "Start Server" button
Sorry I seem to post an earlier config...this is the one I use now, I still get the same error
{
"ws_servers": [{
"host": "pp-2004030254fe.devportal.ptc.io",
"port": 443
}],
"appKey": "4e84018a-03e2-49ff-884d-e65d7067d80f",
"http_server" : {
"host": "127.0.0.1",
"port": 8080,
"use_default_certificate" : true,
"ssl" : false,
"authenticate" : false
},
"logger":{
"level":"INFO"
},
"certificates":{
"validate": false
}
}
Are you able to log into ThingWorx at the URL you are using in the EMS config? The 502 error is returned when your ThingWorx trial server has been automatically shutdown due to inactivity in the Developer Portal guides
Yes I am able to log into the platform and use all the services.
Hello harikj,
I apologize if you have tried this already, but can you ping the Thingworx server from your device? I imagine your EMS is hosted on your Pi OS, so if you could try hitting the server from a terminal session with something like:
telnet pp-2004030254fe.devportal.ptc.io 443
If this results in a blank screen where you can type other commands, that means we are connected fine. Otherwise, an error will appear if the connection on the socket was unsuccessful.
I imagine it will be successful if you are able to log into the platform from a browser on your device (where EMS is installed), so the next thing to check would be the other socket you're trying to use.
In a terminal again:
netstat -a -n -o -p tcp | grep 8080
If something is listed, something else is already using that port.
DEBUG logs should give us more information as well:
"logger":{
"level":"INFO"
},
I tried everything you suggested.
The EMS is hosted on the Pi.
Here are the logs with Logger set to DEBUG
pi@raspberrypi:~/Desktop/microserver $ ./wsems
[FORCE] 2020-04-24 03:35:26,395 ./wsems: Initializing EMS ....
[FORCE] 2020-04-24 03:35:26,395 main: Using config file /home/pi/Desktop/microserver/etc/config.json
[INFO ] 2020-04-24 03:35:26,395 ./wsems: Creating the WsEms proxy.
[DEBUG] 2020-04-24 03:35:26,395 DutyCycle::calculateDutyCycleTimePeriods: m_ConnectPeriod: 60000
[DEBUG] 2020-04-24 03:35:26,395 DutyCycle::calculateDutyCycleTimePeriods: m_DisconnectPeriod: 0
[INFO ] 2020-04-24 03:35:26,395 ./wsems: Starting HTTP Server.
[WARN ] 2020-04-24 03:35:26,395 Main: Encryption is disabled on HTTP Server.
[WARN ] 2020-04-24 03:35:26,395 Main: Authentication is disabled on the HTTP Server.
[INFO ] 2020-04-24 03:35:26,396 ./wsems: Initializing the ThingWorx REST interface.
[FORCE] 2020-04-24 03:35:26,396 httpServer: starting http server port=8080
[DEBUG] 2020-04-24 03:35:26,396 httpServer: http server bound to port=8080.
[INFO ] 2020-04-24 03:35:26,396 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2020-04-24 03:35:26,396 wsEmsProxy::initialize: Encryption is enabled on Web Socket connection.
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize:
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize: EMS Duty Cycle configuration from config.json:
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize: m_DutyCycle.setDutyCyclePeriod: 60000
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize: m_DutyCycle.setDutyCyclePercent: 100
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize: m_DutyCycle.setConnectTimeout: 10000
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize: m_DutyCycle.setConnectRetries: -1
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize: m_DutyCycle.setDelayDutyCycle: 60000
[DEBUG] 2020-04-24 03:35:26,397 wsEmsProxy::initialize:
[WARN ] 2020-04-24 09:05:26,398 SDK: SDK Version: 2.2.0
[WARN ] 2020-04-24 09:05:26,398 SDK: TLS Library: OpenSSL
[WARN ] 2020-04-24 09:05:26,398 SDK: TLS Library Version: 1.0.2l-fips
[WARN ] 2020-04-24 09:05:26,398 SDK: FIPS Capable
[DEBUG] 2020-04-24 09:05:26,398 SDK: twWs_Create: Initializing Websocket Client for pp-19022819274p.portal.ptc.io:443//Thingworx/WS
[DEBUG] 2020-04-24 09:05:26,398 SDK: twTlsClient_Create: Initializing TLS Client
[DEBUG] 2020-04-24 09:05:26,588 SDK: twApi_Initialize: Websocket Established after 0 tries
[DEBUG] 2020-04-24 09:05:26,592 SDK: subscribedPropsMgr_Initialize: Initializing subscribed properties manager
[ERROR] 2020-04-24 09:05:26,593 SDK: twStream_CreateFromFile: error opening file: /opt/thingworx/subscribed_properties.bin
[ERROR] 2020-04-24 09:05:26,593 SDK: subscribedPropsMgr_Initialize: Error opening: /opt/thingworx/subscribed_properties.bin
[INFO ] 2020-04-24 03:35:26,593 WsProxy::initialize: EMS Version 5.4.5.512
[INFO ] 2020-04-24 03:35:26,593 WsProxy::initialize: twApi singleton initialized
[WARN ] 2020-04-24 03:35:26,593 WsProxy::initialize: Certificate validation is disabled.
[DEBUG] 2020-04-24 03:35:26,593 jsonConfigurator::getJsonEntity: Key validation_criteria not found
[DEBUG] 2020-04-24 03:35:26,594 jsonConfigurator::getJsonEntity: Parent file not found
[DEBUG] 2020-04-24 09:05:26,595 SDK: twTunnelManager_Create: Tunnel Manager singleton already exists
[DEBUG] 2020-04-24 03:35:26,594 jsonConfigurator::getJsonEntity: Key auto_bind not found
[INFO ] 2020-04-24 03:35:26,594 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2020-04-24 03:35:26,596 ./wsems: Starting the connection.
pp-19022819274p.portal.ptc.io:443-->[DEBUG] 2020-04-24 09:05:26,597 SDK: twTlsClient_Reconnect: Re-establishing SSL context
[DEBUG] 2020-04-24 09:05:26,623 SDK: twTlsClient_Connect: Connecting to server
[DEBUG] 2020-04-24 09:05:27,481 SDK: twTlsClient_Connect: TLS connection established
[ERROR] 2020-04-24 09:05:30,810 SDK: twWs_Connect: Error initializing web socket. Response code: 502
[DEBUG] 2020-04-24 09:05:35,810 SDK: twTlsClient_Reconnect: Re-establishing SSL context
[DEBUG] 2020-04-24 09:05:35,836 SDK: twTlsClient_Connect: Connecting to server
[DEBUG] 2020-04-24 09:05:36,652 SDK: twTlsClient_Connect: TLS connection established
[ERROR] 2020-04-24 09:05:46,666 SDK: twWs_Connect: Timed out trying to connect
[DEBUG] 2020-04-24 09:05:51,667 SDK: twTlsClient_Reconnect: Re-establishing SSL context
[DEBUG] 2020-04-24 09:05:51,691 SDK: twTlsClient_Connect: Connecting to server
[DEBUG] 2020-04-24 09:05:52,509 SDK: twTlsClient_Connect: TLS connection established
[ERROR] 2020-04-24 09:05:55,834 SDK: twWs_Connect: Error initializing web socket. Response code: 502
Any fixes?