ijsKoud / PaperPlane

An open-source customisable solution to storing files in the cloud. ✈️
https://paperplane.ijskoud.dev
MIT License
8 stars 2 forks source link

Websocket connection to failed: There was a bad response from the server. #215

Closed adi6409 closed 1 year ago

adi6409 commented 1 year ago

Hi, i am trying to deploy paperplane to my raspberry pi 4, and no matter what i try when i access the web panel it just gets stuck on 3 bouncing dots or nothing happens after i press login. in the javascript console it says this: [Error] WebSocket connection to 'wss://hypere.app/websocket' failed: There was a bad response from the server. [Log] ws connection closed – 1006 (_app-bc7ad50d2ae2a128.js, line 1)

i tried via docker, same thing. is there something i'm doing wrong? thanks!

ijsKoud commented 1 year ago

Can you show me the PaperPlane logs (/logs/*.log file), and if possible the startup arguments for Docker

adi6409 commented 1 year ago

sure, im trying to run it via yarn, as for me port 3000 is occupied by mastodon. right now i shut mastodon down while im trying to run paperplane as it keeps defaulting to port 3000 instead of 7173. 1671700526608-v3.1.5-paperplane.log

adi6409 commented 1 year ago

i tried with different versions of paperplane as well.

ijsKoud commented 1 year ago

weird, can you try running it via Docker using the default 3000 port. You can use the --port local:docker flag to change the outgoing port for connections (in this case for you: --port 7173:3000)

adi6409 commented 1 year ago

so using the command: docker run --name=paperplane -d -v ~/paperplane:/paperplane/data -p 7173:3000 ghcr.io/ijskoud/paperplane:v3 it says WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

ijsKoud commented 1 year ago

Oops, that's my fault for not adding a platform list. I am trying to build a dev instance now, it should be available in a couple of minutes.

adi6409 commented 1 year ago

thanks! please let me know when it's available.

ijsKoud commented 1 year ago

ehh it's gonna take a bit longer than expected. For some reason prisma is doing some weird stuff. Will prob be able to provide you with one in a couple of hours if it doesn't work now

adi6409 commented 1 year ago

Alright! take your time! i'm now trying the dev package anyway. i know it won't work, but ill try using that docker image that lets you run anything on arm64

ijsKoud commented 1 year ago

should be ready in a couple of minutes (hopefully)

ijsKoud commented 1 year ago

as far as I know, once this build is complete you can download the dev version using: ghcr.io/ijskoud/paperplane:dev. If it failed, than I will have to look at it tomorrow.

ijsKoud commented 1 year ago

Well looks like it failed once again, will work on it tomorrow if I'm not too busy with other stuff. Sorry for the inconvenience

ijsKoud commented 1 year ago

You can download it now!

adi6409 commented 1 year ago

Thanks, testing.

adi6409 commented 1 year ago
Screenshot 2022-12-22 at 17 04 05 Screenshot 2022-12-22 at 17 04 13

:/

shows 502 error, also showed that while trying with the docker amd64 image using the binfmt image.

adi6409 commented 1 year ago

important to say i'm using the nginx config, while trying to access paperplane from the pi itself it just loops refreshing between err socket not connected and err empty response.

adi6409 commented 1 year ago

changed port to 3000 in both command and .env. now it has the same 3 dots issue. attaching video.

https://user-images.githubusercontent.com/40761968/209168072-3ec14794-c79f-4983-a01c-9f27f1d8835a.mov

ijsKoud commented 1 year ago

Can you change the internal PaperPlane port (the one in Docker, set in the .env file) to 3000?

adi6409 commented 1 year ago

Yup, changed and it now has the same original issue with the websocket error

ijsKoud commented 1 year ago

Oh F, can you show me the NGINX config?

adi6409 commented 1 year ago

NGINX is not the problem, tried without nginx directly using port 3000 and it still had the dots issue.

ijsKoud commented 1 year ago

Ah alright

ijsKoud commented 1 year ago

It could be an issue with your firewall, if you are using your own home network than your firewalls might block a ws connection.

adi6409 commented 1 year ago

yeah i actually don't have a firewall, and i tried a few different networks and none work. also just tried on my M2 macbook pro with the new docker image and it has the same issue! probably forgot to mention it also had the same issue while running paperplane from the source using yarn.

Screenshot 2022-12-23 at 8 41 10
adi6409 commented 1 year ago

interestingly enough, when i run using yarn dev i get this error on the dashboard and index page:

Screenshot 2022-12-23 at 9 10 28
ijsKoud commented 1 year ago

that is a React error and shouldn't break the websocket stuff.

adi6409 commented 1 year ago

yes, but the websocket works on yarn dev. when i run using yarn dev the websocket works and if i go to /login and type username and passwords i get the green notification it redirects me to the dashboard and shows this.

ijsKoud commented 1 year ago

oh that's interesting

adi6409 commented 1 year ago

yup

btw i went to the useAuth.tsx file and swapped the if and the return, so instead of

    const getProtocol = () => {
        const env = process.env.NEXT_PUBLIC_SECURE;
        if (env && env === "false") return "ws://";

        return "wss://";
    };
i put:
        const getProtocol = () => {
        const env = process.env.NEXT_PUBLIC_SECURE;
        if (env && env === "true") return "wss://";

        return "ws://";
    };
ijsKoud commented 1 year ago

Ah you beat me too it. I was about to tell you that I found the issue yea

adi6409 commented 1 year ago

yeah, but even after the change and running yarn build it has the same issue.

ijsKoud commented 1 year ago

It is working as expected, it only didn't work for you in the local environment because you didn't set the NEXT_PUBLIC_SECURE var in .env

adi6409 commented 1 year ago

hmmmmm

in the guide it said SECURE

might be a good idea to attach my .env here, without the generated key:

NAME_TYPE="name" PORT=3000 SECURE=false

(it has port 3000 only for the testing and then i'll switch to 7173)

ill change to NEXT_PUBLIC_SECURE, run yarn build and ill let ya know.

ijsKoud commented 1 year ago

just saw that for some reason the SECURE variable does not really want to work so I will have to find a fix for that.

adi6409 commented 1 year ago

nope didn't work for me ;/

i have two .env files because i dont know which one works, i have one in . and one in ./data. i changed both to include NEXT_PUBLIC_SECURE=false but still error 1006 after running yarn build and yarn start

ijsKoud commented 1 year ago

Yea it has something to do with a env set issue. I am working on a fix

ijsKoud commented 1 year ago

A fix should be ready now, if you run git pull and start the dev or prod version everything should work again.

adi6409 commented 1 year ago

i'll test now, thanks

adi6409 commented 1 year ago

now it shows this.

Screenshot 2022-12-23 at 9 49 56
ijsKoud commented 1 year ago

can you show me the paperplane logs pls

adi6409 commented 1 year ago
Screenshot 2022-12-23 at 9 51 36
adi6409 commented 1 year ago

oh shit im stupid its a database problem

ijsKoud commented 1 year ago

your data.db file is missing

adi6409 commented 1 year ago

forgot to create the data folder

ijsKoud commented 1 year ago

you can run yarn prisma db push to fix it.

adi6409 commented 1 year ago

ended up copying the db file from the other fresh install to data. back to square one :/

Screenshot 2022-12-23 at 9 53 37
adi6409 commented 1 year ago

only now it doesnt even connect to websocket while using yarn dev as well

ijsKoud commented 1 year ago

can you clear your Chrome/FireFox cache, your dist folder and your .next folder. Probably cached javascript being annoying

ijsKoud commented 1 year ago

I also published a Docker Dev version, you can try that one as well if you like.

adi6409 commented 1 year ago

tried deleting the folders and clearing cache, still nothing with yarn start. with yarn dev, however, it worked! i logged into the dashboard. what should i try next?