kyutai-labs / moshi

Apache License 2.0
6.71k stars 516 forks source link

0.0.0.0:8998 web ui can‘t clink connect #86

Closed dcmouth closed 1 month ago

dcmouth commented 1 month ago

Backend impacted

The PyTorch implementation

Operating system

Linux

Hardware

GPU

Description

when i run python -m moshi.server then WX20240920-162156@2x but i can click settings but i can't click connect

Extra information

none

Environment

Fill in the following information on your system.

If the backend impacted is PyTorch:

ubuntu

LaurentMazare commented 1 month ago

Pretty tricky to tell what is going on here:

hugh-min commented 1 month ago

@LaurentMazare Exactly same problem here on a ubuntu server. After clicking "Connect" my Chrome browser will return following message in the browser's console. No error message or anything on the backend.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'addModule') at index-ClFQVzk0.js:431:71092 at index-ClFQVzk0.js:431:71260 at onClick (index-ClFQVzk0.js:431:73819) at Object.Nb (index-ClFQVzk0.js:37:9852) at Tb (index-ClFQVzk0.js:37:10006) at Ub (index-ClFQVzk0.js:37:10063) at nf (index-ClFQVzk0.js:37:31422) at se (index-ClFQVzk0.js:37:31839) at index-ClFQVzk0.js:37:36991 at Qk (index-ClFQVzk0.js:40:36798)

LaurentMazare commented 1 month ago

In this last case, I would guess the issue is on this line where audioContext.audioWorlket is undefined. This seems quite surprising as this has been available in chrome for a long time (chrome 66 in 2018) so not sure what is going on here. You can try this page to see if audio worklets work properly in your browser, but besides that I don't have much ideas to offer.

KaruroChori commented 1 month ago

Use localhost:8998 in place of 0.0.0.0:8998. I had the same issue.

Alex-Songs commented 1 month ago

I had the same issue. are you solved? @KaruroChori

hugh-min commented 1 month ago

I use a Chrome browser with verion 129.0.6668. Could not try localhost:8998 because I use a remote server.

AWAS666 commented 1 month ago

After a bit of research, it appears to be a https issue, audioWorklet is only available in a https context: see here

LaurentMazare commented 1 month ago

I don't think the https restriction applies to localhost actually.

AWAS666 commented 1 month ago

I don't think the https restriction applies to localhost actually.

this only happens if not run on localhost, so for example providing "--host 0.0.0.0"

Alex-Songs commented 1 month ago

@AWAS666 Hi,are you solved?

Alex-Songs commented 1 month ago

@hugh-min Hi, I also use remote server, are you sloved?

hugh-min commented 1 month ago

After a bit of research, it appears to be a https issue, audioWorklet is only available in a https context: see here

confirmed that's the issue

LaurentMazare commented 1 month ago

In that case, you should just tunnel the remote port through ssh so that you can actually use http://localhost:8998 (details in the readme).

dcmouth commented 1 month ago

After a bit of research, it appears to be a https issue, audioWorklet is only available in a https context: see here经过一番研究,它似乎是一个https问题,audioWorklet只在https上下文中可用:请参阅此处

confirmed that's the issue证实这就是问题所在

so what can i do to solve the problem ?

jianglan89 commented 1 month ago

After a bit of research, it appears to be a https issue, audioWorklet is only available in a https context: see here经过一番研究,它似乎是一个https问题,audioWorklet只在https上下文中可用:请参阅此处

confirmed that's the issue证实这就是问题所在

so what can i do to solve the problem ?

  1. gen your CERT_FILE and KEY_FILE use cmd: openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365

  2. update your iptables iptables -A INPUT -p tcp --dport 8998 -j ACCEPT service iptables restart

  3. update server.py and restart server

    CERT_FILE = f'{HOME}/.ssh/cert.pem' KEY_FILE = f'{HOME}/.ssh/key.pem'

    import ssl ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_context.load_cert_chain(certfile=CERT_FILE, keyfile=KEY_FILE) web.run_app(app, port=args.port, ssl_context=ssl_context)

  4. use https://x.x.x.x:8998/

dcmouth commented 1 month ago

After a bit of research, it appears to be a https issue, audioWorklet is only available in a https context: see here经过一番研究,它似乎是一个https问题,audioWorklet只在https上下文中可用:请参阅此处

confirmed that's the issue证实这就是问题所在

so what can i do to solve the problem ?

  1. gen your CERT_FILE and KEY_FILE use cmd: openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
  2. update your iptables iptables -A INPUT -p tcp --dport 8998 -j ACCEPT service iptables restart
  3. update server.py and restart server CERT_FILE = f'{HOME}/.ssh/cert.pem' KEY_FILE = f'{HOME}/.ssh/key.pem' import ssl ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_context.load_cert_chain(certfile=CERT_FILE, keyfile=KEY_FILE) web.run_app(app, port=args.port, ssl_context=ssl_context)
  4. use https://x.x.x.x:8998/

thats great,thx. I solve my problem . according to you notice that is my step below .

(1) openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
(2)sudo update-alternatives --config iptables
and chose iptables-legacy (3)sudo iptables -A INPUT -p tcp --dport 8998 -j ACCEPT
(4) service iptables restart
(5) In moshi/server.py add HOME = os.path.expanduser("~") CERT_FILE = f'{HOME}/cert.pem' KEY_FILE = f'{HOME}/key.pem' import ssl ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_context.load_cert_chain(certfile=CERT_FILE, keyfile=KEY_FILE) web.run_app(app, port=args.port, ssl_context=ssl_context)

then restart server (6)use https://x.x.x.x:8998/

LaurentMazare commented 1 month ago

Just to mention that there is now a --ssl argument for both the pytorch and mlx version so that serving is done over https rather than http. You have to pass to this argument a directory that contains the key and certificate files.