Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on websocket when try to use Ipython notebook in emacs

Got some error message in buffer Warning when try to evaluate my code

Error (websocket): in callback `on-open': Cannot send message to a closed websocket: cl-struct-websocket-frame, text, "{\"header\":{\"msg_id\":\"14735853-0ed2-4ef4-8f5a-312a198dd251\", \"username\":\"username\"\, \"session\":\"ab484abf-d4e6-4f83-2c2-de1b65264780\", \"msg_type\":\"execute_request\"}, \"metadata\":{}, \"content\":{\"code\":\"__import__('sys').stdout.write(__import__('os').getcwd())\", \"silent\":true, \\"user_variables\":[], \"user_expressions\":{}, \"allow_stdin\":false}, \"parent_header\":{}}", nil, t
Error (websocket): in callback `on-open': Wrong type argument: arrayp, nil
Error (websocket): in callback `on-close': Wrong type argument: arrayp, nil

And on the ipython server side I saw this message

2014-03-05 23:24:40.760 [NotebookApp] WARNING | Cross Origin WebSocket Attempt.
2014-03-05 23:24:40.761 [tornado.application] ERROR | Uncaught exception in /kernels/2691bbe3-ce95-439b-a9ce-97ec52c80988/shell
Traceback (most recent call last):
  File "/home/haroldwu/Python-test/lib/python3.3/site-packages/tornado/websocket.py", line 322, in wrapper
    return callback(*args, **kwargs)
  File "/home/haroldwu/Python-test/lib/python3.3/site-packages/IPython/html/base/zmqhandlers.py", line 114, in open
    raise web.HTTPError(404)
tornado.web.HTTPError: HTTP 404: Not Found

What I have done:

  1. Upgrade all package of my python virtualenv and global environment
  2. Upgrade all system package (Archlinux latest 64-bit)
  3. Upgrade all emacs package
  4. Search the web (but found no useful result)

Ipython notebook worked on my emacs weeks ago, but somehow it dosen't work now... I have no experience on tornado.

Thanks for your help!!! :)

like image 608
yfwu Avatar asked Mar 05 '14 15:03

yfwu


1 Answers

I'd guess that emacs is not sending the Origin header which is checked by the Notebook WS code. See my comment https://github.com/ipython/ipython/issues/5525 .

Quick workaround is to comment out the same origin check in your /home/haroldwu/Python-test/lib/python3.3/site-packages/IPython/html/base/zmqhandlers.py:114 .

You can always add logging of parsed_origin, origin and origin_header in same_origin() function in zmqhandlers.py and fix the emacs package accordingly.

like image 158
zxxc Avatar answered Nov 09 '22 22:11

zxxc