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

Self hosted snapdrop is not discoverable between any devices in Docker swarm mode + Traeffik #542

Open
GasimGasimzada opened this issue Nov 23, 2022 · 7 comments

Comments

@GasimGasimzada
Copy link

GasimGasimzada commented Nov 23, 2022

I have deployed a snapdrop instance to a Docker swarm mode inside Raspberry PI. The issue that I have is that, even on the same machine (e.g opening Chrome tab and an incognito tab), the two sessions are not discoverable. When I use snapdrop.net, I can see the devices. Additionally, after 20-30 seconds, I keep seeing errors "WebSocket connection to X failed".

I am not sure what I am doing wrong. In swarm mode, I am using Traeffik for reverse proxy that routes http traffic to snapdrop server + issues automatic certificates. Are there some headers needed for this to work properly.

I tried the single room solution from #159 (comment) as well but that also did not work.

@GasimGasimzada
Copy link
Author

GasimGasimzada commented Nov 23, 2022

After a lot of tinkering with Docker configuration, I finally got it working; however, now I have another issue that only happens in Chromium (I am using Ungoogled Chromium):

Failed to execute 'createAnswer' on 'RTCPeerConnection': PeerConnection cannot create an answer in a state other than have-remote-offer or have-local-pranswer.

Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Failed to set local answer sdp: Called in wrong state: stable

This only happens in Chromium. In general, Chromium cannot send, nor receive any files while Edge, iOS safari etc work fine. I have upgraded it to the latest version as well (v107.0.5304.88)

@DominikTils
Copy link

What’s the advantage of using traefik in your case?
You do not need traefik to successfully deploy snapdrop with docker. #550

About your errors:
I don‘t know whether your first error is a result of you modifications but the second error seems to be common in the unmodified version on snapdrop.net as well (#545 ).
I guess somehow the peer tries to reconnect after the connection is lost, but the RTCPeerConnection is not ready.

Do you manage to reproduce the error on snapdrop.net?

Or have you even successfully fixed the errors?

@DominikTils
Copy link

I am not sure what I am doing wrong. In swarm mode, I am using Traeffik for reverse proxy that routes http traffic to snapdrop server + issues automatic certificates. Are there some headers needed for this to work properly.

When I played around with snapdrop and traefik, I needed to make sure node was exposed on port 3000 and the urls in the docker/nginx/default.conf were changed from http://node:3000 in order to enable connection with the node server.

I could push the config and send you send you a link to the working branch if you like, but apparently you got it working by yourself already 👍

@blipk
Copy link

blipk commented Dec 29, 2022

@DominikTils
I'd appreciate if you could share how you got it working.
I changed the port in the docker compose file to 3000:80 and have disabled my firewall but I still don't have any discoverability. Do you need to change settings in the app?

@schlagmichdoch
Copy link

@blipk you do not need to disable your firewall. Discoverability works by grouping peers with the same ip address.

All devices in one room

To test this you could add the following two line to server/index.js line 184:

    _setIP(request) {
        // edit to put all peers into one room
        this.ip = "0.0.0.0";
        return;
        // end edit

Testing locally

Simply visit 127.0.0.1:3000 from two different browsers or one time normal and one time via inkognito tab.
Then both clients have the same ip address (127.0.0.1) and should be grouped in the same room.

Traefik

A working branch for traefik can be found here:
https://github.com/schlagmichdoch/snapdrop/tree/add_traefik_docker

The specific commit:
0036d17

You can then call your local snapdrop instance by visiting snapdrop.localhost with your browser

@blipk
Copy link

blipk commented Jan 2, 2023

@schlagmichdoch
That doesn't really work for sharing through a LAN network
Is there a way to set multiple IPs or a range or a subnet?

Would be great to have this exposed as an option

@schlagmichdoch
Copy link

@blipk I added a method to differentiate between private and public ip addresses on my instance. All devices that are on the same network as the server use private ip addresses, are therefore put into one room and can discover each other.
I created a PR for that: #558
Woud be great if you could test it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants