tmpnb connection error: No 'Access-Control-Allow-Origin' header

318 views
Skip to first unread message

Timothy Hogan

unread,
Jul 10, 2016, 5:13:43 PM7/10/16
to Project Jupyter
I set up tmpnb on Docker as instructed on Github

It can be accessed via the browser, on http://192.168.99.100:8000. This works as expected

I am trying to connect a "Python Fiddle" type frontend (OReily THEBE) to the tmpnb environment. 

I can connect thebe to "tmpnb.org" and to a kernel running on my local computer. Both work as expected.

When I change the URL to http://192.168.99.100:8000, the connection is not made.

When I check the Web Console I see the following error:

XMLHttpRequest cannot load http://192.168.99.100:8000/api/spawn/. No 'Access-Control-Allow-Origin' header is present on the requested resource.

I have tried starting the notebook, with including the following commands 

--NotebookApp.trust_xheaders=True

--NotebookApp.allow_origin=*


Yet this does not solve the problem.


If I don't use '--NotebookApp.allow_origin=*' on my local computer, when I start up the system, I get the same error. 


I do not see any errors in my docker containers


What additional steps do I need to take?

Thank you!

Kyle Kelley

unread,
Jul 11, 2016, 11:21:33 AM7/11/16
to jup...@googlegroups.com
Hey Timothy,

Both tmpnb _and_ the notebook in the docker container have to change the origin headers for use by Thebe.

For tmpnb, the option is titled --allow-origin (https://github.com/jupyter/tmpnb#options)

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/374fe7d1-ec41-48af-83ac-26ee18b48f9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kyle Kelley (@rgbkrklambdaops.com)

Timothy Hogan

unread,
Jul 11, 2016, 4:41:29 PM7/11/16
to Project Jupyter
Thanks so much Kyle! Your solution worked!

Dhanasekaran Anbalagan

unread,
Jan 12, 2017, 10:38:48 AM1/12/17
to Project Jupyter
Hi Guys,

Currenly I am trying with tmpnb with (OReily THEBE), Currenly I am getting error starting notebook

XMLHttpRequest cannot load http://192.168.70.54:8000/user/MCkTzGFH4xN1?token=fc868fcdf38d1e03d00aeef57bf5f5c91333de3e61e65325/api/kernels. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5555' is therefore not allowed access. The response had HTTP status code 405.

export TOKEN=$( head -c 30 /dev/urandom | xxd -p )
docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=proxy jupyter/configurable-http-proxy --default-target http://127.0.0.1:9999 
docker run -d \
    --net=host \
    --name=tmpnb \
    -e CONFIGPROXY_AUTH_TOKEN=$TOKEN \
    -v /var/run/docker.sock:/docker.sock \
    jupyter/tmpnb \
    python orchestrate.py --use_tokens=1 --image='jupyter/minimal-notebook'  --allow-origin='*' \
        --command='start-notebook.sh \
            "--NotebookApp.base_url={base_path} \
            --ip=0.0.0.0 \
            --port={port} \
            --NotebookApp.trust_xheaders=True" \
   --NotebookApp.allow_origin='*' \
   --NotebookApp.token='''

Web Console I see the following error:
==============================
Thebe is in tmpnb mode
main-built.js:28 cookie was wrong/outdated, call spawn as needed
main-built.js:28 Tmpnb server seems to be up
main-built.js:28 Thebe: start
main-built.js:28 show cell state: start for 0
main-built.js:28 call spawn
main-built.js:28 spawn handler called
main-built.js:28 tmpnb says we should use
jquery-2.1.4.min.js:4 POST http://192.168.70.54:8000/user/MCkTzGFH4xN1?token=fc868fcdf38d1e03d00aeef57bf5f5c91333de3e61e65325/api/kernels send @ jquery-2.1.4.min.js:4ajax @ jquery-2.1.4.min.js:4o.start @ main-built.js:20e.start_kernel @ main-built.js:28(anonymous function) @ main-built.js:28e.spawn_handler @ main-built.js:28(anonymous function) @ main-built.js:28(anonymous function) @ main-built.js:28
(index):1 XMLHttpRequest cannot load http://192.168.70.54:8000/user/MCkTzGFH4xN1?token=fc868fcdf38d1e03d00aeef57bf5f5c91333de3e61e65325/api/kernels. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5555' is therefore not allowed access. The response had HTTP status code 405.
main-built.js:6 Object {readyState: 0, responseJSON: undefined, status: 0, statusText: "error"}
main-built.js:6 API request failed (0): error
main-built.js:28 Ajax Error!
main-built.js:28 Thebe: disconnected

Please guide me How to fix this.

Dhanasekaran Anbalagan

unread,
Jan 13, 2017, 9:35:29 AM1/13/17
to Project Jupyter
Hi Guys,

Finally we are able to run, After adding --NotebookApp.disable_check_xsrf=True

working commands:

export TOKEN=$( head -c 30 /dev/urandom | xxd -p )
docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN jupyter/configurable-http-proxy --default-target http://127.0.0.1:9999
docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN -v /var/run/docker.sock:/docker.sock jupyter/tmpnb python orchestrate.py --image="jupyter/r-notebook" --allow_origin="*" --command="jupyter notebook --no-browser --port {port} --ip=* --NotebookApp.allow_origin=* --NotebookApp.base_url={base_path} --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True" --cull-timeout=300 --cull_period=60
Reply all
Reply to author
Forward
0 new messages