gilmaimon/ArduinoWebsockets

Not able to connect to AWS API Gateway Websockets (ESP8266)

logdog2709 opened this issue · 5 comments

Connecting to AWS API Gateway Websockets
Without fingerprint
-- Connection Closed ([$disconnect] getting called in Cloudwatch logs)
Reason: 1002

With fingerprint
-- No response on serial (No API is getting called)

I am able to connect to the websocket server from cmd.

What might be the issue here?

Hi, let's try to determine the exact issue..

Can you please share the code you are using (or just the relevant parts).

Also, what version of the library are you using?

1002 means that there is a protocol error, I wonder if that error is thrown by the client or server...

I'm sure we'll sort it out.
Gil.

Thanks for responding Gil.
I am using the same code from examples and library v0.4.11.

This is the server URL
wss://bd91q2tled.execute-api.ap-south-1.amazonaws.com/test
This just echos data field
{"action":"message","data":"Echo Data"}

    // run callback when messages are received
    client.onMessage(onMessageCallback);
    
    // run callback when events are occuring
    client.onEvent(onEventsCallback);

    // Before connecting, set the ssl fingerprint of the server
    client.setFingerprint(echo_org_ssl_fingerprint);

    // Connect to server
    client.connect(websockets_connection_string);

    // Send a message
    client.send("{\"action\":\"message\",\"data\": sensorData}");

    // Send a ping
    client.ping();

With this code I was able to connect to the server with client.setInsecure() but handshake was failing.
https://github.com/morrissinger/ESP8266-Websocket/blob/master/examples/WebSocketClient_Demo/WebSocketClient_Demo.ino

Hi,

Thank you, I was able to re-produce and I believe I fixed the issue. Can you pull the changes from master and see if the issue persist?

Gil.

Working like charm. Thanks a lot Gil.

For sure :) Thank you for using the library!