Durable object websocket close not working
Hey, I recently got into Durable objects but I think i'm not getting some parts of it. In my code I was just trying to close the connection immediately after establishing it, but it is not working for some reason and
ws.close
does nothing while ws.send()
works great. This is my code:
3 Replies
Also, for some reason my waitUntil code runs before the handler, which it isn't supposed to do, right?
I'm unsure if waitUntil() is really neccessary here. All methods are called synchronously, there is nothing to await for.
Why are you checking if
ws === server
? getWebSockets() should return all accepted websockets, so all client connections. Thats where you want to send your messages to.I am using waitUntil to actually test if I can actually close the websocket connecton, because if I do ws.close before returning the response, then it will just give me an http error because it did not return the upgrade response. And I am checking if ws === server to only send the message to the client connecting (At least that's what I think "server" represents, because when I do client.send, it doesnt do anything)