New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket.io client connection through AWS Api Gateway #1370
Comments
@Sairyss is there an update on this? |
@JerryLeeCS I ended up using native WebSockets on a client side and $connect, $disconnect and $default routes on a backend side. I didn't find any solution to make it work with Socket.io. Seems like Socket.io connections from the frontend are not supported by AWS Gateway API, it just refuses to connect. |
It seems it's possible: https://stackoverflow.com/a/56364967 |
@darrachequesne If I read that link/so post correctly he is using an EC2 server running SocketIO server? It's a little unclear. I am in the same boat - |
I'm facing the same issue. Using AWS API Gateway Websockets with Lambda Functions for the routes, and I'm seeing multiple 101 responses with super basic code:
|
I spent a bit of time checking the integration of socket.io with AWS API gateway and web socket. As specified here (bottom page): Alternatives:
just change the SOCKET_URL with the wss URL provided by API gateway and it is going to work (as long no authentication is required, if you need authentication as well you will need a bit of more code for providing what API gateway is looking for - either API key or token).
I hope this helps :) |
Did anyone have sucess with the second method suggested by @lucamezzalira, i.e. tunneling the socket.io connection through the API Gateway to an EC2 instance? Possibly with an additional (sticky) Load Balancer? Any suggestions / help is greatly appreciated! |
Hello. I am trying to create a connection like this: socket.io-client -> AWS Gateway API.
While trying to connect from socket.io client to an AWS Gateway API, connection can't be established.
It stucks with a status '101 switching protocols' for a few seconds, then throws 'disconnected' event and tries to reestablish connection, and the process repeats infinitely.
This doesn't happen with native WebSockets or 'ws' library though, everything connects like it should.
I think issue has something to do with how socket.io client and server sides interact with each other by exchanging certain messages which may not be generated on the AWS side of things.
So my question is: is that even possible to establish a connection like this without using proxies:
socket.io-client -> AWS Api Gateway -> socket.io(node.js)
,or it always has to be
Socket.io-client -> socket.io(node.js)
?Amazon AWS documention was used for configuring gateway: https://aws.amazon.com/blogs/compute/announcing-websocket-apis-in-amazon-api-gateway/
It uses standart $connect, $disconnect and $default routes, but instead of lambda its nodejs backend. The issue though is only on the client side.
The text was updated successfully, but these errors were encountered: