Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Pairing not working on self-hosted with Nginx Reverse Proxy #33

Closed
chaosbunker opened this issue Feb 17, 2023 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@chaosbunker
Copy link

chaosbunker commented Feb 17, 2023

Hi there! My issue seems to be similar to #24 .. I successfully set PairDrop up on my server (via Nginx reverse proxy) according to the self-host docs and sharing files works fine. But as soon as I try to pair it says

No server connection. Retry in 5s...

The server is actually unreachable then for a few seconds before returning, when reloading the page immediately I get

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.

In the browser console all I see is

WS: server disconnected [network.js:152:17](https://domain-redacted/scripts/network.js)

The docker logs show the following

pairdrop-node-1  | ----- Uncaught exception -----
pairdrop-node-1  | TypeError: Cannot read property 'getRandomValues' of undefined
pairdrop-node-1  |     at PairDropServer.getRandomString (/home/node/app/index.js:222:30)
pairdrop-node-1  |     at PairDropServer._onPairDeviceInitiate (/home/node/app/index.js:237:31)
pairdrop-node-1  |     at PairDropServer._onMessage (/home/node/app/index.js:146:22)
pairdrop-node-1  |     at WebSocket.<anonymous> (/home/node/app/index.js:106:51)
pairdrop-node-1  |     at WebSocket.emit (events.js:375:28)
pairdrop-node-1  |     at Receiver.receiverOnMessage (/home/node/app/node_modules/ws/lib/websocket.js:1180:20)
pairdrop-node-1  |     at Receiver.emit (events.js:375:28)
pairdrop-node-1  |     at Receiver.dataMessage (/home/node/app/node_modules/ws/lib/receiver.js:541:14)
pairdrop-node-1  |     at Receiver.getData (/home/node/app/node_modules/ws/lib/receiver.js:459:17)
pairdrop-node-1  |     at Receiver.startLoop (/home/node/app/node_modules/ws/lib/receiver.js:158:23)

Self-Hosted
Yes

Self-Hosted Setup
Proxy: Nginx
Deployment: docker-compose

Thanks for your work on PairDrop! Besides the pairing issue it is super reliable and makes our life sharing files between different devices/platforms easy!

edit:

For reference, here is my nginx configuration

upstream snapdrop {
	server pairdrop-node-1:3000;
}

server {
	listen 80;
	server_name domain-redacted;
	return 301 https://$host$request_uri;
}

server {
	listen 443 ssl http2;
	server_name domain-redacted;
	ssl_certificate /etc/nginx/ssl/domain-redacted/cert.pem;
	ssl_certificate_key /etc/nginx/ssl/domain-redacted/key.pem;
	include /etc/nginx/includes/ssl.conf;
	include /etc/nginx/includes/gzip.conf;

	expires epoch;

	location / {
		proxy_connect_timeout 300;
		proxy_pass http://snapdrop;
		proxy_set_header Connection "upgrade";
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header X-Forwarded-for $remote_addr;
	}

	location ~ /.well-known {
		allow all;
		root /var/www/html;
	}
}
@schlagmichdoch
Copy link
Owner

Thanks for all the information! Makes debugging much easier!
Your Nginx config looks good and as files sharing works the issue is not to be found there.

TypeError: Cannot read property 'getRandomValues' of undefined

means that crypto.webcrypto does not exist for the node server. This is an unexpectected error that causes the server to crash and restart.

I'll try to reproduce the issue and come back to you

@schlagmichdoch
Copy link
Owner

crypto.webcrypto and crypto.webcrypto.getRandomValues(typedArray) need Node.js v15.0.0 or above.

When I use the given docker-compose file I cannot reproduce your issue as node:lts-alpine is used which currently points to v18.14.0.
When I replace node:lts-alpine with node:14-alpine version v14.21.2 is installed and the behaviour is exactly as you described.

  • Have you changed the docker-compose.yml?
  • What is the output of docker-compose run node node -v

schlagmichdoch added a commit that referenced this issue Feb 17, 2023
schlagmichdoch added a commit that referenced this issue Feb 17, 2023
@schlagmichdoch schlagmichdoch added the bug Something isn't working label Feb 17, 2023
@chaosbunker
Copy link
Author

Ha! Not a bug, then - just a silly oversight on my end. You pointed me in the right direction by referencing the correct node version. I had an outdated and unused node:lts-alpine image 'lying around', so when i did docker-compose up -d it just used that and I didn't notice. Good reminder to purge unused docker images:)

Now running PairDrop with the most recent node:lts-alpine and pairing works as expected. I'm so happy, this is incredibly useful! Thanks so much:)

@schlagmichdoch
Copy link
Owner

Perfect!
It appears you can prevent this by running docker-compose pull before which pulls the latest image if an update is available.
https://www.baeldung.com/ops/docker-compose-latest-image
I guess I will add this to the documentation.

Glad it works now and you like it :)

schlagmichdoch added a commit that referenced this issue Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants