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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Error 404 when connecting to websocket via thingworx C sdk

sonali92jain
5-Regular Member

Error 404 when connecting to websocket via thingworx C sdk

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.

 

[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.

3 REPLIES 3

Hello,

 

Take a look at this article (CS2663600) and see if it is applicable to your use case.

 

 

Thanks,

 

-- Craig A.

sonali92jain
5-Regular Member
(To:CRArko)

Hi @CRArko

 

I tried the resolution points given in the article, but the wsems is still giving me a 

"Connect: Error initializing web socket. Response code: 404" 

 

 

Is this behind a proxy server or do you have an external firewall? With the 404 response you're getting and the apparent html response, any chance this is behind a reverse proxy server?

 

Thanks,

 

-- Craig A.

Top Tags