alphacep / vosk-server

WebSocket, gRPC and WebRTC speech recognition server based on Vosk and Kaldi libraries
Apache License 2.0
918 stars 248 forks source link

1006 and 1011 websocket errors during recognition #80

Closed sashker closed 3 years ago

sashker commented 3 years ago

Hello.

Thank you for the amazing job you've done.

Currently, I do my tests on the docker container provided, with the Websocket server. I randomly receive errors from the server with the 1006 and 1011 codes. I use the same file with approx. 10 minutes length and send chunks of a wav-file from my custom go-client.

The exception on the server looks like this:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/websockets/protocol.py", line 684, in transfer_data yield from self._put_message_waiter concurrent.futures._base.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/websockets/server.py", line 169, in handler yield from self.ws_handler(self, path) File "./asr_server.py", line 74, in recognize await websocket.send(response) File "/usr/lib/python3/dist-packages/websockets/protocol.py", line 462, in send yield from self.ensure_open() File "/usr/lib/python3/dist-packages/websockets/protocol.py", line 658, in ensure_open ) from self.transfer_data_exc websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason

nshmyrev commented 3 years ago

This error means that your client doesn't respond to server ping frames. You need to fix your client library to do that.

nshmyrev commented 3 years ago

Similar issue with php

https://github.com/Textalk/websocket-php/pull/87

if you provide information on your go library, we can take a look.

sashker commented 3 years ago

Yes, could be. )) Probably, the python client does that automatically...

I'm currently using github.com/sacOO7/gowebsocket

I'll double-check ping/pong's and reply back asap.

Thank you.

nshmyrev commented 3 years ago

Ok, looking on this code I think you should manually send back pong message in onPingRecieved handler.

sashker commented 3 years ago

I've changed the library to https://godoc.org/nhooyr.io/websocket. This library automatically responses to ping and it does - I can see ping/pong in a Wireshark dump. But the server still does interrupt the session due to client's timeout. (the vanilla python client works well, though).

nshmyrev commented 3 years ago

You can uncomment logging here:

https://github.com/alphacep/vosk-server/blob/b9de19139425b2522a2f5586ad4ffe0fd2f6a0ab/websocket/asr_server.py#L13

and see what happened on the server side.

sashker commented 3 years ago

For those who use Golang - make sure that your library supports automatic/manual Pong, and make sure that your context does not cancel the client by timeout.