alphacep / vosk-server

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

Connection Is Being Refused on the Docker Vosk server #117

Closed EziamakaNV closed 3 years ago

EziamakaNV commented 3 years ago

Hello, I installed the vosk server as specified on the website. I tried running the test "./test.py test.wav" as as stated in the site as well, and I kept getting a connection refused error. I'm currently running the program on an aws ec2 instance with 32 vCPUs and 64GB memory. Please find the error below:

[ec2-user@ip-172-31-8-234 websocket]$ ./test.py test.wav Traceback (most recent call last): File "./test.py", line 23, in hello('ws://localhost:2700')) File "/usr/lib64/python3.7/asyncio/base_events.py", line 587, in run_untilcomplete return future.result() File "./test.py", line 8, in hello async with websockets.connect(uri) as websocket: File "/home/ec2-user/.local/lib/python3.7/site-packages/websockets/legacy/client.py", line 604, in _aenter_ return await self File "/home/ec2-user/.local/lib/python3.7/site-packages/websockets/legacy/client.py", line 622, in _await_impl__ transport, protocol = await self._create_connection() File "/usr/lib64/python3.7/asyncio/base_events.py", line 962, in create_connection raise exceptions[0] File "/usr/lib64/python3.7/asyncio/base_events.py", line 949, in create_connection await self.sock_connect(sock, address) File "/usr/lib64/python3.7/asyncio/selector_events.py", line 473, in sock_connect return await fut File "/usr/lib64/python3.7/asyncio/selector_events.py", line 503, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 2700)

nshmyrev commented 3 years ago

Server is not running? Did you check the server output?

nshmyrev commented 3 years ago

It also might be that localhost points to ipv6, you need to check that it forwards to 127.0.0.1 instead.

EziamakaNV commented 3 years ago

Server is not running? Did you check the server output?

You were right, the docker service wasn't running. I restarted and tried testing again, but got a connection reset error

ConnectionResetError: [Errno 104] Connection reset by peer

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

Traceback (most recent call last): File "./test.py", line 23, in hello('ws://127.0.0.1:2700')) File "/usr/lib64/python3.7/asyncio/base_events.py", line 587, in run_until_complete return future.result() File "./test.py", line 8, in hello async with websockets.connect(uri) as websocket: File "/home/ec2-user/.local/lib/python3.7/site-packages/websockets/legacy/client.py", line 604, in aenter return await self File "/home/ec2-user/.local/lib/python3.7/site-packages/websockets/legacy/client.py", line 634, in __await_impl__ extra_headers=protocol.extra_headers, File "/home/ec2-user/.local/lib/python3.7/site-packages/websockets/legacy/client.py", line 382, in handshake status_code, response_headers = await self.read_http_response() File "/home/ec2-user/.local/lib/python3.7/site-packages/websockets/legacy/client.py", line 198, in read_http_response raise InvalidMessage("did not receive a valid HTTP response") from exc websockets.exceptions.InvalidMessage: did not receive a valid HTTP response

nshmyrev commented 3 years ago

Looks like you have something else running on 2700, that is why server is not starting. You can check with netstat.

EziamakaNV commented 3 years ago

Looks like you have something else running on 2700, that is why server is not starting. You can check with netstat.

Ran the check with netstat. Its the vosk docker server that's running on 2700

[ec2-user@ip-172-31-8-234 websocket]$ sudo netstat -plnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:36391 0.0.0.0: LISTEN 4267/containerd
tcp 0 0 0.0.0.0:2700 0.0.0.0:
LISTEN 9682/docker-proxy
tcp 0 0 0.0.0.0:111 0.0.0.0: LISTEN 3482/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:
LISTEN 4914/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0: LISTEN 4364/master
tcp6 0 0 :::111 :::
LISTEN 3482/rpcbind
tcp6 0 0 :::22 :::* LISTEN 4914/sshd

I changed the local host IP in the test.py file to 0.0.0.0:2700 and I was still getting the same ConnectionResetError

nshmyrev commented 3 years ago

What is the docker server output from the start to the point you get connection reset error?

EziamakaNV commented 3 years ago

What is the docker server output from the start to the point you get connection reset error?

Hi, there wasn't any output. Nothing came up on the docker logs for the container that's running

nshmyrev commented 3 years ago

If you start container in non-daemon mode (without -d) there must be messages.

EziamakaNV commented 3 years ago

If you start container in non-daemon mode (without -d) there must be messages.

I restarted the container in non-daemon mode like you suggested to view the messages and the test started working. I don't understand why lol. Thanks a lot for helping me clear this up. Much appreciated 💯