odelot / aws-mqtt-websockets

Implementation of a middleware to use AWS MQTT service through websockets, aiming the ESP8266 plataform
GNU Lesser General Public License v3.0
231 stars 67 forks source link

Eratic connection #54

Open apicquot opened 5 years ago

apicquot commented 5 years ago

I manage to connect / publish / subscribe but the connection works pretty randomly and may takes many attempts. The connection is stable once established. Any idea what it could be ?

Here under 2 consecutive loops, one fails the second works....

[WS-Client] client disconnected. [WS-Client] connect wss... State: sending Client Hello (1) State: receiving Server Hello (2) State: receiving Certificate (11) === CERTIFICATE ISSUED TO === Common Name (CN): .iot.us-west-2.amazonaws.com Organization (O): Basic Constraints: critical, CA:FALSE, pathlen:10000 Key Usage: critical, Digital Signature, Key Encipherment Subject Alt Name: iot.us-west-2.amazonaws.com .iot.us-west-2.amazonaws.com === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Not Before: Thu Aug 2 00:00:00 2018 Not After: Fri Aug 2 12:00:00 2019 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:0 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Not Before: Thu Oct 22 00:00:00 2015 Not After: Sun Oct 19 00:00:00 2025 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Not Before: Mon May 25 12:00:00 2015 Not After: Thu Dec 31 01:00:00 2037 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Organization (O): Starfield Technologies, Inc. Organizational Unit (OU): Starfield Class 2 Certification Authority Country (C): US Not Before: Wed Sep 2 00:00:00 2009 Not After: Wed Jun 28 17:39:16 2034 RSA bitsize: 2048 Sig Type: SHA256 State: receiving Server Hello Done (14) State: sending Client Key Exchange (16) State: sending Finished (16) State: receiving Finished (16) [WS-Client] connected to MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443. [WS-Client][sendHeader] sending header... [WS-Client][sendHeader] handshake GET /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F19700101%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=19700101T080004Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=77145f9661eb7e049b4b3d670d268f3eb2da39f0e38c42b72061de1a6eaed150 HTTP/1.1 Host: MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443 Connection: Upgrade Upgrade: websocket Sec-WebSocket-Version: 13 Sec-WebSocket-Key: BqqtCJcdb4cqFzjx3BWKjQ== Sec-WebSocket-Protocol: mqtt Origin: file:// User-Agent: arduino-WebSocket-Client

[write] n: zu t: 559 [WS-Client][sendHeader] sending header... Done (78040us). [WS-Client][handleHeader] RX: HTTP/1.1 403 Forbidden [WS-Client][handleHeader] RX: content-type: application/json [WS-Client][handleHeader] RX: content-length: 163 [WS-Client][handleHeader] RX: date: Wed, 20 Feb 2019 02:33:14 GMT [WS-Client][handleHeader] RX: x-amzn-RequestId: e5b733f6-071e-27d7-38c6-523dbe228518 [WS-Client][handleHeader] RX: connection: keep-alive [WS-Client][handleHeader] RX: x-amzn-ErrorType: ForbiddenException: [WS-Client][handleHeader] RX: access-control-allow-origin: [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorMessage [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-RequestId [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorType [WS-Client][handleHeader] RX: access-control-expose-headers: Date [WS-Client][handleHeader] Header read fin. [WS-Client][handleHeader] Client settings: [WS-Client][handleHeader] - cURL: /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F19700101%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=19700101T080004Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=77145f9661eb7e049b4b3d670d268f3eb2da39f0e38c42b72061de1a6eaed150 [WS-Client][handleHeader] - cKey: BqqtCJcdb4cqFzjx3BWKjQ== [WS-Client][handleHeader] Server header: [WS-Client][handleHeader] - cCode: 403 [WS-Client][handleHeader] - cIsUpgrade: 0 [WS-Client][handleHeader] - cIsWebsocket: 0 [WS-Client][handleHeader] - cAccept: [WS-Client][handleHeader] - cProtocol: mqtt [WS-Client][handleHeader] - cExtensions: [WS-Client][handleHeader] - cVersion: 0 [WS-Client][handleHeader] - cSessionId: [WS-Client][handleHeader] no Websocket connection close. [write] n: zu t: 27 Alert: close notify [WS-Client] client disconnected. [WS-Client] client disconnected. [WS-Client] connect wss... State: sending Client Hello (1) State: receiving Server Hello (2) State: receiving Certificate (11) === CERTIFICATE ISSUED TO === Common Name (CN): .iot.us-west-2.amazonaws.com Organization (O): Basic Constraints: critical, CA:FALSE, pathlen:10000 Key Usage: critical, Digital Signature, Key Encipherment Subject Alt Name: iot.us-west-2.amazonaws.com *.iot.us-west-2.amazonaws.com === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Not Before: Thu Aug 2 00:00:00 2018 Not After: Fri Aug 2 12:00:00 2019 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:0 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Not Before: Thu Oct 22 00:00:00 2015 Not After: Sun Oct 19 00:00:00 2025 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Not Before: Mon May 25 12:00:00 2015 Not After: Thu Dec 31 01:00:00 2037 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Organization (O): Starfield Technologies, Inc. Organizational Unit (OU): Starfield Class 2 Certification Authority Country (C): US Not Before: Wed Sep 2 00:00:00 2009 Not After: Wed Jun 28 17:39:16 2034 RSA bitsize: 2048 Sig Type: SHA256 State: receiving Server Hello Done (14) State: sending Client Key Exchange (16) State: sending Finished (16) State: receiving Finished (16) [WS-Client] connected to MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443. [WS-Client][sendHeader] sending header... [WS-Client][sendHeader] handshake GET /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F19700101%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=19700101T080004Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=77145f9661eb7e049b4b3d670d268f3eb2da39f0e38c42b72061de1a6eaed150 HTTP/1.1 Host: MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443 Connection: Upgrade Upgrade: websocket Sec-WebSocket-Version: 13 Sec-WebSocket-Key: sA+TUDFa86ZvL5Ztmh4O/Q== Sec-WebSocket-Protocol: mqtt Origin: file:// User-Agent: arduino-WebSocket-Client

[write] n: zu t: 559 [WS-Client][sendHeader] sending header... Done (79310us). [WS-Client][handleHeader] RX: HTTP/1.1 403 Forbidden [WS-Client][handleHeader] RX: content-type: application/json [WS-Client][handleHeader] RX: content-length: 163 [WS-Client][handleHeader] RX: date: Wed, 20 Feb 2019 02:33:17 GMT [WS-Client][handleHeader] RX: x-amzn-RequestId: e1ed6f31-decb-fcfc-2dbe-bb7df7cfb315 [WS-Client][handleHeader] RX: connection: keep-alive [WS-Client][handleHeader] RX: x-amzn-ErrorType: ForbiddenException: [WS-Client][handleHeader] RX: access-control-allow-origin: [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorMessage [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-RequestId [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorType [WS-Client][handleHeader] RX: access-control-expose-headers: Date [WS-Client][handleHeader] Header read fin. [WS-Client][handleHeader] Client settings: [WS-Client][handleHeader] - cURL: /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F19700101%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=19700101T080004Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=77145f9661eb7e049b4b3d670d268f3eb2da39f0e38c42b72061de1a6eaed150 [WS-Client][handleHeader] - cKey: sA+TUDFa86ZvL5Ztmh4O/Q== [WS-Client][handleHeader] Server header: [WS-Client][handleHeader] - cCode: 403 [WS-Client][handleHeader] - cIsUpgrade: 0 [WS-Client][handleHeader] - cIsWebsocket: 0 [WS-Client][handleHeader] - cAccept: [WS-Client][handleHeader] - cProtocol: mqtt [WS-Client][handleHeader] - cExtensions: [WS-Client][handleHeader] - cVersion: 0 [WS-Client][handleHeader] - cSessionId: [WS-Client][handleHeader] no Websocket connection close. [write] n: zu t: 27 Alert: close notify [WS-Client] client disconnected. [WS-Client] client disconnected. [WS-Client] connect wss... State: sending Client Hello (1) State: receiving Server Hello (2) State: receiving Certificate (11) === CERTIFICATE ISSUED TO === Common Name (CN): .iot.us-west-2.amazonaws.com Organization (O): Basic Constraints: critical, CA:FALSE, pathlen:10000 Key Usage: critical, Digital Signature, Key Encipherment Subject Alt Name: iot.us-west-2.amazonaws.com *.iot.us-west-2.amazonaws.com === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Not Before: Thu Aug 2 00:00:00 2018 Not After: Fri Aug 2 12:00:00 2019 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:0 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Not Before: Thu Oct 22 00:00:00 2015 Not After: Sun Oct 19 00:00:00 2025 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Not Before: Mon May 25 12:00:00 2015 Not After: Thu Dec 31 01:00:00 2037 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Organization (O): Starfield Technologies, Inc. Organizational Unit (OU): Starfield Class 2 Certification Authority Country (C): US Not Before: Wed Sep 2 00:00:00 2009 Not After: Wed Jun 28 17:39:16 2034 RSA bitsize: 2048 Sig Type: SHA256 State: receiving Server Hello Done (14) State: sending Client Key Exchange (16) State: sending Finished (16) State: receiving Finished (16) [WS-Client] connected to MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443. [WS-Client][sendHeader] sending header... [WS-Client][sendHeader] handshake GET /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F19700101%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=19700101T080004Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=77145f9661eb7e049b4b3d670d268f3eb2da39f0e38c42b72061de1a6eaed150 HTTP/1.1 Host: MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443 Connection: Upgrade Upgrade: websocket Sec-WebSocket-Version: 13 Sec-WebSocket-Key: 6kN3CrJ2IdF3Jy9nx4tgrQ== Sec-WebSocket-Protocol: mqtt Origin: file:// User-Agent: arduino-WebSocket-Client

[write] n: zu t: 559 [WS-Client][sendHeader] sending header... Done (78657us). [WS-Client][handleHeader] RX: HTTP/1.1 403 Forbidden [WS-Client][handleHeader] RX: content-type: application/json [WS-Client][handleHeader] RX: content-length: 163 [WS-Client][handleHeader] RX: date: Wed, 20 Feb 2019 02:33:19 GMT [WS-Client][handleHeader] RX: x-amzn-RequestId: 612ceea9-8bb1-73d9-3cb1-f3b117766e94 [WS-Client][handleHeader] RX: connection: keep-alive [WS-Client][handleHeader] RX: x-amzn-ErrorType: ForbiddenException: [WS-Client][handleHeader] RX: access-control-allow-origin: [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorMessage [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-RequestId [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorType [WS-Client][handleHeader] RX: access-control-expose-headers: Date [WS-Client][handleHeader] Header read fin. [WS-Client][handleHeader] Client settings: [WS-Client][handleHeader] - cURL: /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F19700101%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=19700101T080004Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=77145f9661eb7e049b4b3d670d268f3eb2da39f0e38c42b72061de1a6eaed150 [WS-Client][handleHeader] - cKey: 6kN3CrJ2IdF3Jy9nx4tgrQ== [WS-Client][handleHeader] Server header: [WS-Client][handleHeader] - cCode: 403 [WS-Client][handleHeader] - cIsUpgrade: 0 [WS-Client][handleHeader] - cIsWebsocket: 0 [WS-Client][handleHeader] - cAccept: [WS-Client][handleHeader] - cProtocol: mqtt [WS-Client][handleHeader] - cExtensions: [WS-Client][handleHeader] - cVersion: 0 [WS-Client][handleHeader] - cSessionId: [WS-Client][handleHeader] no Websocket connection close. [write] n: zu t: 27 Alert: close notify [WS-Client] client disconnected. [WS-Client] client disconnected. failed, rc=-256389 - conn: 2 - (41176) [WS-Client] client disconnected. [WS-Client] connect wss... State: sending Client Hello (1) State: receiving Server Hello (2) State: receiving Certificate (11) === CERTIFICATE ISSUED TO === Common Name (CN): .iot.us-west-2.amazonaws.com Organization (O): Basic Constraints: critical, CA:FALSE, pathlen:10000 Key Usage: critical, Digital Signature, Key Encipherment Subject Alt Name: iot.us-west-2.amazonaws.com *.iot.us-west-2.amazonaws.com === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Not Before: Thu Aug 2 00:00:00 2018 Not After: Fri Aug 2 12:00:00 2019 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Organization (O): Amazon Organizational Unit (OU): Server CA 1B Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:0 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Not Before: Thu Oct 22 00:00:00 2015 Not After: Sun Oct 19 00:00:00 2025 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Amazon Root CA 1 Organization (O): Amazon Country (C): US Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Not Before: Mon May 25 12:00:00 2015 Not After: Thu Dec 31 01:00:00 2037 RSA bitsize: 2048 Sig Type: SHA256 === CERTIFICATE ISSUED TO === Common Name (CN): Starfield Services Root Certificate Authority - G2 Organization (O): Starfield Technologies, Inc. Location (L): Scottsdale Country (C): US State (ST): Arizona Basic Constraints: critical, CA:TRUE, pathlen:10000 Key Usage: critical, Digital Signature, Key Cert Sign, CRL Sign === CERTIFICATE ISSUED BY === Common Name (CN): Organization (O): Starfield Technologies, Inc. Organizational Unit (OU): Starfield Class 2 Certification Authority Country (C): US Not Before: Wed Sep 2 00:00:00 2009 Not After: Wed Jun 28 17:39:16 2034 RSA bitsize: 2048 Sig Type: SHA256 State: receiving Server Hello Done (14) State: sending Client Key Exchange (16) State: sending Finished (16) State: receiving Finished (16) [WS-Client] connected to MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443. [WS-Client][sendHeader] sending header... [WS-Client][sendHeader] handshake GET /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F20190220%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=20190220T023320Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ae191dc65e77d05ddbb6edff1c6e255bab2afb2d3436a1d7b23065c03331c81a HTTP/1.1 Host: MY_ENDPOINT-ats.iot.us-west-2.amazonaws.com:443 Connection: Upgrade Upgrade: websocket Sec-WebSocket-Version: 13 Sec-WebSocket-Key: 7ohN4jIx+1/rQmEro5dWlA== Sec-WebSocket-Protocol: mqtt Origin: file:// User-Agent: arduino-WebSocket-Client

[write] n: zu t: 559 [WS-Client][sendHeader] sending header... Done (78718us). [WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols [WS-Client][handleHeader] RX: content-length: 0 [WS-Client][handleHeader] RX: upgrade: websocket [WS-Client][handleHeader] RX: connection: upgrade [WS-Client][handleHeader] RX: sec-websocket-accept: DNS6xlnM82WiR4Wm0ikqp7GjSuI= [WS-Client][handleHeader] RX: sec-websocket-protocol: mqtt [WS-Client][handleHeader] RX: access-control-allow-origin: * [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorMessage [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-RequestId [WS-Client][handleHeader] RX: access-control-expose-headers: x-amzn-ErrorType [WS-Client][handleHeader] RX: access-control-expose-headers: Date [WS-Client][handleHeader] Header read fin. [WS-Client][handleHeader] Client settings: [WS-Client][handleHeader] - cURL: /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MY_ACCES_KEY%2F20190220%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=20190220T023320Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ae191dc65e77d05ddbb6edff1c6e255bab2afb2d3436a1d7b23065c03331c81a [WS-Client][handleHeader] - cKey: 7ohN4jIx+1/rQmEro5dWlA== [WS-Client][handleHeader] Server header: [WS-Client][handleHeader] - cCode: 101 [WS-Client][handleHeader] - cIsUpgrade: 1 [WS-Client][handleHeader] - cIsWebsocket: 1 [WS-Client][handleHeader] - cAccept: DNS6xlnM82WiR4Wm0ikqp7GjSuI= [WS-Client][handleHeader] - cProtocol: mqtt [WS-Client][handleHeader] - cExtensions: [WS-Client][handleHeader] - cVersion: 0 [WS-Client][handleHeader] - cSessionId: [WS-Client][handleHeader] Websocket connection init done.

odelot commented 5 years ago

Hi @apicquot . Maybe it is the NTP service to get the current timestamp to sign the aws login.

There are two ways to do it in the library (although you can't choose it lol). The default is by a ntp server. The other one is by the amazon http response.

I've noticed that the ntp server many times does not return the current timestamp.

You can set the library to get the current timestamp from amazon setting _useAmazonTimestamp = true;in the library constructor. Try it and see if it fixes your problem.

(if it fixes, it would be nice to debug why ntp server is not responding accordingly. I think getting the timestamp from ntp server is safer than get from a http response that can be changed and lose this info)