zorchenhimer / MovieNight

Single instance video streaming server with integrated chat.
https://discord.gg/F2VSgjJ
MIT License
683 stars 87 forks source link

Not installing correctly (Ubuntu 18.04.02 LTS) #79

Closed Raisum closed 5 years ago

Raisum commented 5 years ago

Hi, I seem to have an issue with installing MovieNight. It doesn't seem to fully install or its missing files with the command: "go get -u -v github.com/zorchenhimer/MovieNight".

go version: go version go1.12 linux/amd64

GNU make version: GNU Make 4.1

Here's what it writes in terminal: go get -u -v github.com/zorchenhimer/MovieNight github.com/zorchenhimer/MovieNight (download) created GOPATH=/home/humble/go; see 'go help gopath' github.com/gorilla/websocket (download) github.com/nareix/joy4 (download) github.com/satori/go.uuid (download) github.com/lucasb-eyer/go-colorful (download)

and here's the directory of go/bin: ls $HOME/go/bin MovieNight

zorchenhimer commented 5 years ago

This is probably a case of poor and/or misleading documentation. I'll fire up an Ubuntu VM and get back to you.

Raisum commented 5 years ago

I got it working after some trial and error. I had to: cd $HOME/go/src/github.com/zorchenhimer/MovieNight type these commands: make get GOOS=js GOARCH=wasm go build -o ./static/main.wasm wasm/*.go

Copy /static/ folder from $HOME/go/src/github.com/zorchenhimer/MovieNight to $HOME/root/go/bin Copy settings_example.json from $HOME/go/src/github.com/zorchenhimer/MovieNight to $HOME/root/go/bin as settings.json

And then it started to work for me. Now I'm gonna try to reverse proxy it, but thanks for the help.

joeyak commented 5 years ago

@zorchenhimer, I think we will have to change the documentation to say run make in the folder, and then run it from their. I don't think it is a good idea to clutter up the go/bin with movienight specific folders and files. Also maybe generate settings.json if it is not present.

cd $GOROOT/src/zorchenhimer/MovieNight
make
cp settings_example.json settings.json
./MovieNight
zorchenhimer commented 5 years ago

Yea, I figured it was probably caused by not finding the settings or static files. go get not compiling the wasm file completely slipped my mind though.

As for a reverse proxy, if you use Nginx, I've been using this configuration without much issue:

upstream movienight {
        server 127.0.0.1:8089;
}

server {
        listen 80;
        server_name example.com;
        location / {
                proxy_pass http://movienight;
        }

        location /ws {
                proxy_pass http://movienight;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

If you're using Apache or HAProxy, I'm afraid I can't really help you there.

Raisum commented 5 years ago

I got the stream and the site proxied just fine, but the chat is having some issues. I also changed the ws:// to wss:// in chat.js as you described it here but I'm guessing that's still a work in progress. This is my Nginx config:

location /stream/ {
    proxy_pass http://localhost:8089/;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Ssl on;
    proxy_set_header x-forwarded-proto $scheme;
    proxy_set_header x-forwarded-port $server_port;
    proxy_read_timeout  90;
    proxy_redirect http://127.0.0.1:8089/ https://$host;
}
location /live {
    proxy_pass http://localhost:8089/live;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Ssl on;
    proxy_set_header x-forwarded-proto $scheme;
    proxy_set_header x-forwarded-port $server_port;
    proxy_read_timeout  90;
    proxy_redirect http://127.0.0.1:8089/live https://$host;
}
location /ws {
    proxy_pass http://localhost:8089/ws;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

And here's the errors I get in DevTools:

TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
WebAssembly.instantiateStreaming.then.catch @ chat.js:46
Promise.catch (async)
startGo @ chat.js:45
window.addEventListener @ chat.js:279
load (async)
(anonymous) @ chat.js:276
chat.js:98 Uncaught ReferenceError: isValidName is not defined
    at join (chat.js:98)
    at HTMLInputElement.onclick ((index):115)
join @ chat.js:98
onclick @ (index):115
joeyak commented 5 years ago

Not sure about the first error, but I think the isValidName error is because the HTML loads before the wasm file is finished downloading. The HTML input onclick tries to say "this is the function" before the wasm defines it.

zorchenhimer commented 5 years ago

It sounds like the wasm file isn't being sent with the correct Content-Type header. It should be sent automatically, but it might help to explicitly send it.

But yea, the "isValidName is not defined" error is because the onclick event fires off before the wasm has been loaded. That will be taken care of with #72.

As for your Nginx config, there are a few things that stick out. First, you're forwarding some SSL headers, but SSL isn't currently handled in the server yet. Nginx would have to handle and strip the SSL then proxy to an HTTP localhost address. SSL support on the server is planned eventually, however.

Second, you're sending a bunch of headers that are ignored. This shouldn't cause any issues, but I figured I'd point them out anyway. X-Forwarded-For is the only one that's read, and it's only used for bans when it is.

The extra stuff in the Nginx config shouldn't cause any issues, but it seems you may be over complicating it. The config I shared above is exactly what I use live (I only changed the server_name before sharing).

Raisum commented 5 years ago

Yeah about the Nginx config, I just copied from my other proxied sites (I am using Plesk and I'm hosting multiple websites from it) and it doesn't seem to cause any issues. But thanks for the help!

zorchenhimer commented 5 years ago

A load notification has been added in ccecc6476. Can you confirm that this works for you now?

Raisum commented 5 years ago

Aye it works now, thanks! There was still a small issue of setting the go paths when I tried to reinstall, using the make command it couldn't find goimports. I had to use these commands to fix it: export PATH=$PATH:/usr/local/go/bin export GOPATH=$HOME/go; export PATH=$PATH:$GOPATH/bin;

zorchenhimer commented 5 years ago

Awesome!

Side note, setting of GOPATH should be done as part of the Go installation.