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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Error 404 when connecting to websocket via thingworx C sdk and wsems

sonali92jain
5-Regular Member

Error 404 when connecting to websocket via thingworx C sdk and wsems

Hi,

I am following the C SDK guide and working with 194-C-SDK-1-4-0( version 1.4.0). I am working from a windows 10 laptop and built the SteamSensor example with VS 2017. On executing the program, my connection is established fine but all API calls to the thingworx is returning 404 error.

 

I also tried to execute the wsems and it is giving me the same issue.

 

Logs for wsems

[FORCE] 2018-05-03 10:27:20,917 C:\CDEMO_EMS\wsems.exe: Initializing EMS ....
[FORCE] 2018-05-03 10:27:20,917 main: Using config file C:\CDEMO_EMS\etc\config.json
[INFO ] 2018-05-03 10:27:20,917 C:\CDEMO_EMS\wsems.exe: Creating the WsEms proxy.
[INFO ] 2018-05-03 10:27:20,917 C:\CDEMO_EMS\wsems.exe: Starting HTTP Server.
[INFO ] 2018-05-03 10:27:20,917 Main: Using custom certificate and private key for HTTP Server
[WARN ] 2018-05-03 10:27:20,917 Main: Encryption is disabled on HTTP Server.
[WARN ] 2018-05-03 10:27:20,917 Main: Authentication is disabled on the HTTP Server.
[INFO ] 2018-05-03 10:27:20,917 C:\CDEMO_EMS\wsems.exe: Initializing the ThingWorx REST interface.
[INFO ] 2018-05-03 10:27:20,917 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2018-05-03 10:27:20,917 wsEmsProxy::initialize: Encryption is enabled on Web Socket connection.
[WARN ] 2018-05-03 10:27:20,917 SDK: SDK Version: 2.0.4
[WARN ] 2018-05-03 10:27:20,917 SDK: TLS Library: OpenSSL
[WARN ] 2018-05-03 10:27:20,917 SDK: TLS Library Version: 1.0.2l
[WARN ] 2018-05-03 10:27:20,917 SDK: FIPS Capable
[FORCE] 2018-05-03 10:27:20,918 httpServer: starting http server port=8000
[INFO ] 2018-05-03 10:27:21,123 SDK: twOffLineMsgStore_SetDir: Created offline message file /opt/thingworx/offline_msgs.bin
[INFO ] 2018-05-03 10:27:21,123 WsProxy::initialize: EMS Version 5.4.0.114
[INFO ] 2018-05-03 10:27:21,123 WsProxy::initialize: twApi singleton initialized
[WARN ] 2018-05-03 10:27:21,123 WsProxy::initialize: Certificate validation is disabled.
[ERROR] 2018-05-03 10:27:21,124 SDK: twMap_Add: parse function returned null.
[INFO ] 2018-05-03 10:27:21,124 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2018-05-03 10:27:21,124 C:\CDEMO_EMS\wsems.exe: Starting the connection.
[ERROR] 2018-05-03 10:27:22,111 SDK: twWs_Connect: Error initializing web socket. Response code: 404
[ERROR] 2018-05-03 10:27:27,939 SDK: twWs_Connect: Error initializing web socket. Response code: 404
[ERROR] 2018-05-03 10:27:33,214 SDK: twWs_Connect: Error initializing web socket. Response code: 404

 

logs for C SDK

[FORCE] 2018-05-03 14:57:50,441: Starting up
[DEBUG] 2018-05-03 14:57:50,442: twWs_Create: Initializing Websocket Client for xx-xxxxxxxxxxxx.devportal.ptc.io:443//Thingworx/WS
[DEBUG] 2018-05-03 14:57:50,443: twTlsClient_Create: Initializing TLS Client
[DEBUG] 2018-05-03 14:57:50,505: twApi_Initialize: Websocket Established after 0 tries
[INFO ] 2018-05-03 14:57:50,514: twOffLineMsgStore_SetDir: Created offline message file /opt/thingworx/offline_msgs.bin
[DEBUG] 2018-05-03 14:57:50,514: subscribedPropsMgr_Initialize: Initializing subscribed properties manager
[TRACE] 2018-05-03 14:57:50,521: All property subscriptions have been received from the server. Subscribed properties can now be updated.
[DEBUG] 2018-05-03 14:57:50,531: added SteamSensor1 to boundList
[DEBUG] 2018-05-03 14:57:50,533: twApi_BindThings: not currently connected, only binding things to api
[DEBUG] 2018-05-03 14:57:50,535: twMessage_Delete: Deleting BIND Message: 1
[TRACE] 2018-05-03 14:57:50,535: twApi_Connect: Delaying 8921 milliseconds before connecting
[DEBUG] 2018-05-03 14:57:59,457: twTlsClient_Reconnect: Re-establishing SSL context
[DEBUG] 2018-05-03 14:57:59,457: twTlsClient_Connect: Connecting to server
[DEBUG] 2018-05-03 14:58:00,131: twTlsClient_Connect: TLS connection established
[TRACE] 2018-05-03 14:58:00,132: twWs_Connect: Connected to xx-xxxxxxxxxxxx.devportal.ptc.io:443
[TRACE] 2018-05-03 14:58:00,132: twWs_Connect: Sent request:
GET /Thingworx/WS HTTP/1.1
User-Agent: ThingWorx C SDK
Upgrade: websocket
Connection: Upgrade
Host: xx-xxxxxxxxxxxx.devportal.ptc.io
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 98CETG2Su+gXVWg6Vj4Dqg==
Max-Frame-Size: 8192
appKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx


[TRACE] 2018-05-03 14:58:00,437: twTlsClient_Read: Read: 295, Asked for: 8192
[TRACE] 2018-05-03 14:58:00,437: twWs_Connect: Got Response from Server:

HTTP/1.1 404
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: frame-ancestors 'self'
X-Frame-Options: SAMEORIGIN
Content-Type: text/html;charset=ISO-8859-1
Date: Thu, 03 May 2018 09:25:24 GMT
Content-Length: 708
Age: 422
Via: HTTPS/1.1 Proxy

 

[ERROR] 2018-05-03 14:58:00,438: twWs_Connect: Error initializing web socket. Response code: 404
[DEBUG] 2018-05-03 14:58:05,439: twTlsClient_Reconnect: Re-establishing SSL context
[DEBUG] 2018-05-03 14:58:05,440: twTlsClient_Connect: Connecting to server
[DEBUG] 2018-05-03 14:58:06,19: twTlsClient_Connect: TLS connection established
[TRACE] 2018-05-03 14:58:06,20: twWs_Connect: Connected to xx-xxxxxxxxxxxx.devportal.ptc.io:443
[TRACE] 2018-05-03 14:58:06,20: twWs_Connect: Sent request:
GET /Thingworx/WS HTTP/1.1
User-Agent: ThingWorx C SDK
Upgrade: websocket
Connection: Upgrade
Host: xx-xxxxxxxxxxxx.devportal.ptc.io
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: wP05V3nPC0yemjpNLXZQTw==
Max-Frame-Size: 8192
appKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx


[TRACE] 2018-05-03 14:58:06,214: twTlsClient_Read: Read: 295, Asked for: 8192
[TRACE] 2018-05-03 14:58:06,214: twWs_Connect: Got Response from Server:

HTTP/1.1 404
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: frame-ancestors 'self'
X-Frame-Options: SAMEORIGIN
Content-Type: text/html;charset=ISO-8859-1
Date: Thu, 03 May 2018 09:25:29 GMT
Content-Length: 708
Age: 421
Via: HTTPS/1.1 Proxy

 

[ERROR] 2018-05-03 14:58:06,216: twWs_Connect: Error initializing web socket. Response code: 404
[DEBUG] 2018-05-03 14:58:11,217: twTlsClient_Reconnect: Re-establishing SSL context
[DEBUG] 2018-05-03 14:58:11,219: twTlsClient_Connect: Connecting to server
[DEBUG] 2018-05-03 14:58:11,316: twTlsClient_Connect: TLS connection established
[TRACE] 2018-05-03 14:58:11,317: twWs_Connect: Connected to xx-xxxxxxxxxxxx.devportal.ptc.io:443
[TRACE] 2018-05-03 14:58:11,319: twWs_Connect: Sent request:
GET /Thingworx/WS HTTP/1.1
User-Agent: ThingWorx C SDK
Upgrade: websocket
Connection: Upgrade
Host: xx-xxxxxxxxxxxx.devportal.ptc.io
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 6xuj8M2Z98v5IX0bnrKM7g==
Max-Frame-Size: 8192
appKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx


[TRACE] 2018-05-03 14:58:11,545: twTlsClient_Read: Read: 295, Asked for: 8192
[TRACE] 2018-05-03 14:58:11,546: twWs_Connect: Got Response from Server:

HTTP/1.1 404
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: frame-ancestors 'self'
X-Frame-Options: SAMEORIGIN
Content-Type: text/html;charset=ISO-8859-1
Date: Thu, 03 May 2018 09:25:35 GMT
Content-Length: 708
Age: 422
Via: HTTPS/1.1 Proxy

 

[ERROR] 2018-05-03 14:58:11,552: twWs_Connect: Error initializing web socket. Response code: 404
[ERROR] 2018-05-03 14:58:16,554: twApi_Connect: Max number of connect retries: 3, has been reached
[ERROR] 2018-05-03 14:58:16,554: main: Server connection failed after 3 attempts. Error Code: 201

 

Any help would be greatly appreciated.

1 REPLY 1

Hi @sonali92jain would it be possible to share WSEMS's config.json file? It appears that you are attempting secure connection go the platform both via WSEMS or C SDK, I hope the connection string to the ThingWorx in the configuration file is set accordingly and ThingWorx is responding on HTTPS connections?

Top Tags