Replies: 2 comments 1 reply
-
The WebSocket implementation in Microdot does not have any timeouts. But it is fairly common for web servers, proxy servers or clients to include timeouts after some idle time. Are you sure these timeouts aren't happening somewhere else? In any case, you can send a dummy message every once in a while to prevent the timeout. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply! function send_data(msg) { |
Beta Was this translation helpful? Give feedback.
-
Hello
the websocket connection closes if it is not used after a certain time. If I initialize a new websocket connection in Javascript (let socket = new WebSocket('ws://' + location.host + '/echo');) the message arrives with a new websocket instance on the Micropyten server. However, the response to the client is then lost - probably because of the new websocket instance that was initialized by the client (?)
Is this behavior normal? How can I initiate a bidirectional working websocket connection from the client - without reloading the page again?
Thanks for a hint!
@app.route('/echo')
@with_websocket
async def echo(request, ws):
data = await ws.receive()
await ws.send(data)
Beta Was this translation helpful? Give feedback.
All reactions