Skip to content
Advertisement

GoneException when calling post_to_connection on AWS lambda and API gateway

I want to send a message to a websocket client when it connects to the server on AWS lambda and API gateway. Currently, I use wscat as a client. Since the response ‘connected’ is not shown on the wscat console when I connect to the server, I added post_to_connection to send a message ‘hello world’ to the client. However, it raises GoneException.

An error occurred (GoneException) when calling the PostToConnection operation

How can I solve this problem and send some message to wscat when connecting to the server?

My python code is below. I use Python 3.8.5.

JavaScript

Advertisement

Answer

Self-answer: you cannot post_to_connection to the connection itself in onconnect.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement