jupyterlite / jupyterlab-webrtc-docprovider

Document collaboration for JupyterLab and JupyterLite, powered by y-webrtc
BSD 3-Clause "New" or "Revised" License
6 stars 5 forks source link

Find one or more recommendable self-hosted WebRTC signaling servers #4

Open bollwyvl opened 2 years ago

bollwyvl commented 2 years ago

Problem

Anyhow, what I haven't explored yet is a simple, self-hosted signaling server to recommend, e.g. as a jupyterhub service: relying on unmirrorable, public/free services at runtime is always shady, I think it would be a good solution for many use cases, already, over a user sharing the jupyter_server instance :scream:.

from https://github.com/jupyterlite/jupyterlite/issues/598#issuecomment-1102877998

Suggested Improvement

knoxell commented 9 months ago

I came across this problem some time ago and started using the y-webrtc-signaling 'binary' from y-webrtc.

The y-webrtc-signaling source file bin/server.js should also give anyone wanting to implement the signaling server in python a good starting point.

Running a signaling server using nodejs

1. Setup the signaling server

For anyone wanting to give it a go, you need nodejs and npm and than just run in a directory where npm can install your project

# install y-webrtc package into your current folder
$ npm i y-webrtc
$ PORT=4444 npx y-webrtc-signaling
Signaling server running on localhost: 4444

It says running on localhost, but it's actually listening on 0.0.0.0, meaning it's listening on all network interfaces, so all the IPs your machine has.

2. Configure jupyterlite (running jupyterlab-webrtc-docprovider)

2.1 Configure jupyterlite manually use your signaling server

In Jupyter do:

  1. click on Settings
  2. click on Settings Editor/Advanced Settings Editor
  3. scroll to the bottom of the list to WebRTC Sharing and click on it
  4. under Signaling URLs choose custom signaling servers
  5. click on Add
  6. enter ws://YOUR_IP_OR_HOSTNAME:4444

    2.2 Configure jupyterlite to automatically use your signaling server

    put the following in your overrides.json

    {
    "@jupyterlite/webrtc-docprovider:plugin": {
        "signalingUrls": [
            "ws://YOUR_IP_OR_HOSTNAME:4444"
        ]
    }
    }

    Notes

    Your signaling server can run under localhost/127.0.0.1 (YOUR_IP_OR_HOSTNAME), but your jupiterlite cant (I don't know why, probably part of the webrtc security model..). For local testing I just run both on 127.0.0.10, because my local ip changes a lot.

This setup is just for testing!