So you're a Noob? Post your questions here until you graduate! Don't be shy.
User avatar
By Sushant Naik
#72336 i am trying to connect esp to aws IOT cloud, i was trying odelot example from here https://github.com/odelot/aws-mqtt-websockets, i think i have done all part right as, i have just edited
the user part like

Code: Select allchar wifi_ssid[]       = "Guren Mark II";
char wifi_password[]   = "lellouchrebellion";
char aws_endpoint[]    = "apigateway.ap-northeast-1.amazonaws.com";
char aws_key[]         = "AKIAJVBP557SD6JXUL5Q";
char aws_secret[]      = "34Ru7MgSAurwLtyZD1FxZZZCdE801Nb/KBUY9wZo";
char aws_region[]      = "ap-northeast-1";
const char* aws_topic  = "$aws/things/esp8266/shadow/update";


but i am unable to connect to the thing on cloud,

Code: Select allWS-Client] connected to apigateway.ap-northeast-1.amazonaws.com:443.
[WS-Client][sendHeader] sending header...
[WS-Client][sendHeader] handshake GET /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJVBP557SD6JXUL5Q%2F20171206%2Fap-northeast-1%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=20171206T101413Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=7cd2dddeb3482f56e78abeab26f25a6db5788516bee9a111766100c029fba5dd HTTP/1.1
Host: apigateway.ap-northeast-1.amazonaws.com
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: NS5E9gfGdQWh7JBpCt2C2A==
Sec-WebSocket-Protocol: mqtt
Origin: file://
User-Agent: arduino-WebSocket-Client

[write] n: 554 t: 13504
[WS-Client][sendHeader] sending header... Done (314530us).
[WS-Client][handleHeader] RX: HTTP/1.1 403 Forbidden
[WS-Client][handleHeader] RX: Date: Wed, 06 Dec 2017 10:14:21 GMT
[WS-Client][handleHeader] RX: Content-Length: 141
[WS-Client][handleHeader] RX: Connection: keep-alive
[WS-Client][handleHeader] RX: x-amzn-RequestId: 3a3d6858-da6e-11e7-9130-497e406180df
[WS-Client][handleHeader] RX: Access-Control-Allow-Origin: *
[WS-Client][handleHeader] RX: Access-Control-Expose-Headers: x-amzn-RequestId,x-amzn-ErrorType,x-amzn-ErrorMessage,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=AKIAJVBP557SD6JXUL5Q%2F20171206%2Fap-northeast-1%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=20171206T101413Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=7cd2dddeb3482f56e78abeab26f25a6db5788516bee9a111766100c029fba5dd
[WS-Client][handleHeader]  - cKey: NS5E9gfGdQWh7JBpCt2C2A==
[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: 27 t: 13924
[WS-Client] client disconnected.
[WS-Client] connect wss...
this is error log i have found as per shown in this issue on github https://github.com/odelot/aws-mqtt-websockets/issues/7

i tried to remove port as suggested in comment but no changes,

could anybody help

Thanks
Sushant
User avatar
By villTech
#72339 make sure that AWS IoT is set up correctly and the credentials are all correct.
checking via AWS IoT Test Client will do.

I tried to use the credentials you posted (not sure if you really posted it correctly though), but I was not able to connect to WS server. mine is connecting just fine.