danijel3 / KaldiWebrtcServer

Python server for communicating with Kaldi from the browser using WebRTC
Apache License 2.0
67 stars 37 forks source link

doesn't work on ubuntu #1

Open NonaryR opened 5 years ago

NonaryR commented 5 years ago

Hello, @danijel3 ! Nice work, I have tested this on macbook and all works well, but on Ubuntu after I click Start button, and allowed use micro, all pending in Connecting status. In docker logs I see this

web_1    | [2019-04-08 19:24:37,573] ice <INFO> Connection(0) Check CandidatePair(('172.27.0.3', 45489) -> ('192.168.1.2', 43511)) State.FROZEN -> State.WAITING
web_1    | [2019-04-08 19:24:37,573] ice <INFO> Connection(0) Check CandidatePair(('172.27.0.3', 45489) -> ('192.168.1.2', 43511)) State.WAITING -> State.IN_PROGRESS
kaldi_1  | LOG (online2-tcp-nnet3-decode-faster[5.5.259~1-25269]:Accept():online2-tcp-nnet3-decode-faster.cc:364) Accepted connection from: 172.27.0.3
web_1    | [2019-04-08 19:24:37,575] ice <INFO> Connection(0) Check CandidatePair(('172.27.0.3', 45489) -> ('192.168.1.2', 43511)) failed : source address mismatch
web_1    | [2019-04-08 19:24:37,575] ice <INFO> Connection(0) Check CandidatePair(('172.27.0.3', 45489) -> ('192.168.1.2', 43511)) State.IN_PROGRESS -> State.FAILED
web_1    | [2019-04-08 19:24:37,575] ice <INFO> Connection(0) ICE failed
web_1    | [2019-04-08 19:24:37,576] web <INFO> Connected to Kaldi server kaldi:5050...

Specifically -- source address mismatch, which doesn't appear on macbook. What should I check for this?

danijel3 commented 5 years ago

Thank you for this first issue report!

It seems that the server and the browser aren't running on the same computer, am I right?

Are they on the same network? How is this exactly used?

NonaryR commented 5 years ago

I just pointed that on macbook all working well, but on ubuntu I have source address mismatch log and connecting status forever. I'm simply using docker-compose)

NonaryR commented 5 years ago

may be I don't have some drivers for it? can I check this somehow?

danijel3 commented 5 years ago

The example in the repo is designed mostly for running the the demo on the same computer as the browser. If you run them on different computers, you may run into issues. That is why I'm asking.

Judging from the IP addresses on the screenshot above, it seemed to me that the server was on a different computer, but maybe I'm mistaken.

The docker component should work the same anywhere, so even on a mac. The browsers, on the other hand... are you using Safari? I had some issues on Firefox. I think there is a bug in the javascript code somewhere...

NonaryR commented 5 years ago

ohh, my bad, but I didn't know that -- it not work while I'm connecting to service in incognito page from google chrome. Sorry for disturbing, again, thanks for your project!

P.S. -- can you please share how you train you model? Which dataset you used or model?

NonaryR commented 5 years ago

@danijel3 one more question locally service working just fine, and I decided to deploy it in google cloud, just for fun =) But when I click on connect button, status pending to "Connecting" and this happens in logs:

web_1    | [2019-04-10 15:47:31,358] ice <INFO> Connection(0) Check CandidatePair(('172.29.0.3', 44931) -> ('172.17.0.7', 62522)) State.WAITING -> State.IN_PROGRESS
web_1    | [2019-04-10 15:48:34,861] ice <INFO> Connection(0) Check CandidatePair(('172.29.0.3', 44931) -> ('192.168.1.3', 61759)) State.IN_PROGRESS -> State.FAILED
web_1    | [2019-04-10 15:48:34,866] ice <INFO> Connection(0) Check CandidatePair(('172.29.0.3', 44931) -> ('172.17.0.7', 62522)) State.IN_PROGRESS -> State.FAILED
web_1    | [2019-04-10 15:48:34,866] ice <INFO> Connection(0) ICE failed

What am I missing? I'm allowed on VM udp ports 0-65535 and tcp 0-65535 (this is bad practice, but just for debug puprose)

NonaryR commented 5 years ago

I'm thinking that config in RTCPeerConnection need be specified, but how?

danijel3 commented 5 years ago

There are two things at play here:

  1. most browser will complain if you want to send your voice to a remote location without encryption. To enable a remote service, you will need to create a certificate, which means you will need a computer that has a domain name assigned to it. Fortunately, if you have an HTTPS server somewhere, you can use those certificates directly in the server.
  2. You need to enable stun, by adding a line in the config, like you suspected. The line is:
    config.iceServers = [{urls: ['stun:stun.l.google.com:19302']}];

right before the RTCPeerConnection construction, as you mention above.

NonaryR commented 5 years ago

I add stun urls as you suggest and declare in docker-compose.yml, in web service

ports:
  - "19302:19302/udp"

But still have this issue(

danijel3 commented 5 years ago

You shouldn't need to open the UDP ports. It's a peer-to-peer connection. Should work fine without it.

Did you make sure you're not getting any errors in the browser?

My docker-compose.yml looks like this:

version: '3.3'
services:
  kaldi:
    image: "danijel3/kaldi-online-tcp:PL"
  web:
    image: "danijel3/kaldi-webrtc"
    volumes:
      - ${PWD}/client.js:/server/static/client.js
      - ${PWD}/servers.json:/server/servers.json
      - /etc/ssl/certs/my.crt:/server/server.crt
      - /etc/ssl/private/my.pem:/server/server.key
    entrypoint:
      - python3
      - /server/server.py
      - --servers=/server/servers.json
      - --cert-file=/server/server.crt
      - --key-file=/server/server.key
    ports:
      - "8080:8080"
NonaryR commented 5 years ago

I have certificates generated by certbot for https, but have this error

web_1    | [2019-04-10 20:30:48,698] asyncio <ERROR> SSL handshake failed
web_1    | protocol: <asyncio.sslproto.SSLProtocol object at 0x7f303e2396d8>
web_1    | transport: <_SelectorSocketTransport fd=7 read=polling write=<idle, bufsize=0>>
web_1    | Traceback (most recent call last):
web_1    |   File "/usr/lib/python3.7/asyncio/sslproto.py", line 625, in _on_handshake_complete
web_1    |     raise handshake_exc
web_1    |   File "/usr/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata
web_1    |     self._sslobj.do_handshake()
web_1    |   File "/usr/lib/python3.7/ssl.py", line 763, in do_handshake
web_1    |     self._sslobj.do_handshake()
web_1    | ssl.SSLError: [SSL: HTTP_REQUEST] http request (_ssl.c:1056)
web_1    | [2019-04-10 20:30:48,712] asyncio <ERROR> SSL error in data received
web_1    | protocol: <asyncio.sslproto.SSLProtocol object at 0x7f303e2396d8>
web_1    | transport: <_SelectorSocketTransport closing fd=7 read=idle write=<idle, bufsize=0>>
web_1    | Traceback (most recent call last):
web_1    |   File "/usr/lib/python3.7/asyncio/sslproto.py", line 526, in data_received
web_1    |     ssldata, appdata = self._sslpipe.feed_ssldata(data)
web_1    |   File "/usr/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata
web_1    |     self._sslobj.do_handshake()
web_1    |   File "/usr/lib/python3.7/ssl.py", line 763, in do_handshake
web_1    |     self._sslobj.do_handshake()
web_1    | ssl.SSLError: [SSL: HTTP_REQUEST] http request (_ssl.c:1056)

I'm used this args

"--cert-file","/server/fullchain.pem", "--key-file","/server/privkey.pem"

But this is not important for now, because I deploy service and use Firefox instead of Chrome, FF allowed using micro by http In web-console I see just this

ICE failed, add a TURN server and see about:webrtc for more details