googlecolab / jupyter_http_over_ws

Apache License 2.0
267 stars 56 forks source link

0.0.7 make impossible to connect collab to jupyter through a proxy. #12

Closed alexis-gruet-deel closed 4 years ago

alexis-gruet-deel commented 4 years ago

Everything in the title, Last update to 0.0.7 make impossible to connect collab to a jupyter instance through a proxy.

[Collab] --> [Local proxy ws://] --> -LAN- --> [GPU server running a jupyter instance.]

The following trace is observable on the jupyter instance :

[E 19:36:25.303 NotebookApp] Uncaught error when proxying request
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/jupyter_http_over_ws/handlers.py", line 178, in _attach_auth_cookies
        _validate_same_domain(self.request, parsed_auth_url)
      File "/usr/local/lib/python2.7/dist-packages/jupyter_http_over_ws/handlers.py", line 503, in _validate_same_domain
        handler_domain.geturl(), url.geturl()))
    ValueError: Invalid cross-domain request from http://192.168.1.119:8888 to http://localhost:8899/
[E 19:36:25.304 NotebookApp] Couldn't attach auth cookies

The port :8899 is the localhost computer where collab is launched. (my workstation) This is also a proxy redirecting the wsocket request to an internal lan server serving jupyter : 192.168.1.119 on the port 8888.

Jupyter is launch with the following options :

jupyter notebook --NotebookApp.allow_origin='' --port=8888 --ip='0.0.0.0' --NotebookApp.port_retries=0 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.disable_check_xsrf=True  --allow-root --no-browser

Was working on 0.0.6. Any advices ?

alexis-gruet-deel commented 4 years ago

Fixed .. by overriding the _AUTH_URL_QUERY_PARAM with the jupyter instance url || another way is to change the jupyter_http_over_ws_auth_url from the GET request with the IP of the jupyter instance.

jobdiogenes commented 4 years ago

Fixed .. by overriding the _AUTH_URL_QUERY_PARAM with the jupyter instance url || another way is to change the jupyter_http_over_ws_auth_url from the GET request with the IP of the jupyter instance. I stay have the same problem.

I install pip3 install jupyter_http_over_ws or from git, both get the same problem.

alexis-gruet-deel commented 4 years ago

I don't really remember.. I guess pip3 install and then updated directly the code under the pip3 install placeholder for jupyter. Hint :

rgrep -i _AUTH_URL_QUERY_PARAM /usr/ should give you this placeholder.

jobdiogenes commented 4 years ago

as result of grep -i _AUTH_URL_QUERY_PARAM Found in 'handlers.py' where has: _AUTH_URL_QUERY_PARAM = 'jupyter_http_over_ws_auth_url'

You suggest to change to something like: _AUTH_URL_QUERY_PARAM = "127.0.0.1:8888"

Is this?

alexis-gruet-deel commented 4 years ago

I had to re-deploy a docker with tf2.1.0 with jupyter on a local GPU instance (in my LAN). On my desktop computer (mac) I installed Whistle proxy (nodejs) and set those 2 rules

^ws://localhost:8899/http_over_websocket?min_version=0.0.7&jupyter_http_over_ws_auth_url=http%3A%2F%2Flocalhost%3A8899%2F ws://192.168.1.119:8899/http_over_websocket?min_version=0.0.7&jupyter_http_over_ws_auth_url=http%3A%2F%2F192.168.1.119%3A8899
^ws://localhost:8899/http_over_websocket/proxied_ws/api/kernels/***/channels?session_id=***&jupyter_http_over_ws_auth_url=*** ws://192.168.1.119:8899/http_over_websocket/proxied_ws/api/kernels/$1/channels?session_id=$2&jupyter_http_over_ws_auth_url=http%3A%2F%2F192.168.1.119%3A8899

Where 192.168.1.119 is my local GPU. This will redirect the websocket stream from colab to my local GPU and make it works perfectly.

I just notice something, if you launch a long task (say a training) don't reload colab othwerwise you will not be able to reconnect/re-bind the colab notebook (limitation of jupyter itself)

mathfac commented 4 years ago

Thank you @MI-LA01 your solution works! I had the same issue, when actual machine jupyter notebook is running isn't local host. I used the Eternal Terminal with port forwarding. I had to patch handlers.py file: vim /home/ubuntu/anaconda3/lib/python3.6/site-packages/jupyter_http_over_ws/handlers.py Change _AUTH_URL_QUERY_PARAM = "jupyter_http_over_ws_auth_url" => _AUTH_URL_QUERY_PARAM = "127.0.0.1:8888"

Then Colab start connecting to local remote GPU empowered machine successfully. Command I used to run Jupyter: jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8891 --ip='0.0.0.0' --NotebookApp.port_retries=0 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.disable_check_xsrf=True --allow-root --no-browser