klen / asgi-tools

Tools to build ASGI apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ASGITestClient doesn't send websocket close code on disconnect

villekr opened this issue · comments

ASGITestClient doesn't send websocket close code, which is mandatory value in ASGI specification. Currently only "type" is send.
https://asgi.readthedocs.io/en/latest/specs/www.html#disconnect-receive-event-ws

    async def disconnect(self):
        await self.send({'type': 'websocket.disconnect'})
        self.state = self.STATES.disconnected

WebSocket error codes:
https://datatracker.ietf.org/doc/html/rfc6455#section-7.4

@villekr Thank you 🙏. The client has been updated (asgi-tools 0.61.5).

Works now. Thanks for quick fix!