tkf / emacs-ipython-notebook

IPython notebook client in Emacs
tkf.github.com/emacs-ipython-notebook/
GNU General Public License v3.0
548 stars 51 forks source link

Issue with Ipython 1.2.1 on Aquamacs (websocket error) #141

Open thoo opened 10 years ago

thoo commented 10 years ago

I have Enthought Python and Anaconda . I have been using Enthought Ipython (version 1.1 ) without any problem. Now if I switch to anaconda with ipython version 1.2.1, I keep getting this error without any output.

Error (websocket): in callback on-open': Cannot send message to a closed websocket: cl-struct-websocket-frame, text, "{\"header\":{\"msg_id\":\"904aba3a-8bbf-4662-8fc9-361d3662692f\",\"username\":\"username\",\"session\":\"a284e887-329e-4dbb-8ce9-869151e7e84a\",\"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 callbackon-open': Wrong type argument: arrayp, nil Error (websocket): in callback on-close': Wrong type argument: arrayp, nil Error (websocket): in callbackon-open': Wrong type argument: arrayp, nil Error (websocket): in callback `on-close': Wrong type argument: arrayp, nil

erikcw commented 10 years ago

I'm getting the same error but I'm running plain (emacs)[http://emacsformacosx.com/] on OSX 10.9.

Check list

Description of the problem you have

I can open notebooks in emacs, but when I try to execute the contents of a cell, I get the following in the *Warnings* buffer:

Error (websocket): in callback `on-open': Cannot send message to a closed websocket: cl-struct-websocket-frame, text, "{\"header\":{\"msg_id\":\"be2a517b-487d-4e68-bbd7-5fa3b23b892a\", \"username\":\"username\", \"session\":\"f67ba66f-30e3-45e9-8be0-4af49b9395f5\", \"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

When run from the "Quick try" zeroein.el script, I get this in my *Warnings* buffer:

Error found in callback `on-close': (ein:$websocket-onclose accessing a non-ein:$websocket)

The ipython notebook process in my terminal outputs the following:

Eriks-MacBook-Air:retargeting erik$ ipython notebook --port 8555
2014-03-20 11:30:16.420 [NotebookApp] Using existing profile dir: u'/Users/erik/.ipython/profile_default'
2014-03-20 11:30:16.425 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-03-20 11:30:16.436 [NotebookApp] Serving notebooks from local directory: /Users/erik/Dropbox/home/git/retargeting
2014-03-20 11:30:16.436 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8555/
2014-03-20 11:30:16.436 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
2014-03-20 11:30:48.102 [NotebookApp] Connecting to: tcp://127.0.0.1:63025
2014-03-20 11:30:48.103 [NotebookApp] Kernel started: 1dda8602-2f19-474b-8eac-49508feca422
2014-03-20 11:30:48.578 [NotebookApp] WARNING | Cross Origin WebSocket Attempt.
2014-03-20 11:30:48.579 [tornado.application] ERROR | Uncaught exception in /kernels/1dda8602-2f19-474b-8eac-49508feca422/shell
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/tornado/websocket.py", line 322, in wrapper
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/IPython/html/base/zmqhandlers.py", line 114, in open
    raise web.HTTPError(404)
HTTPError: HTTP 404: Not Found
2014-03-20 11:30:48.589 [NotebookApp] WARNING | Cross Origin WebSocket Attempt.
2014-03-20 11:30:48.589 [tornado.application] ERROR | Uncaught exception in /kernels/1dda8602-2f19-474b-8eac-49508feca422/iopub
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/tornado/websocket.py", line 322, in wrapper
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/IPython/html/base/zmqhandlers.py", line 114, in open
    raise web.HTTPError(404)
HTTPError: HTTP 404: Not Found
2014-03-20 11:30:48.590 [tornado.application] ERROR | Uncaught exception, closing connection.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/tornado/iostream.py", line 354, in wrapper
    callback(*args)
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
    raise_exc_info(exc)
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
    ret = fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/tornado/httpserver.py", line 218, in _on_connection_close
    callback()
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
    raise_exc_info(exc)
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
    ret = fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/tornado/websocket.py", line 293, in on_connection_close
    self.on_close()
  File "/usr/local/lib/python2.7/site-packages/IPython/html/services/kernels/handlers.py", line 131, in on_close
    if self.kernel_id in km:
AttributeError: 'IOPubHandler' object has no attribute 'kernel_id'
2014-03-20 11:30:48.593 [tornado.application] ERROR | Exception in callback <functools.partial object at 0x109289e68>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/tornado/ioloop.py", line 477, in _run_callback
    callback()
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
    raise_exc_info(exc)
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
    ret = fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/tornado/iostream.py", line 354, in wrapper
    callback(*args)
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
    raise_exc_info(exc)
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
    ret = fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/tornado/httpserver.py", line 218, in _on_connection_close
    callback()
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
    raise_exc_info(exc)
  File "/usr/local/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
    ret = fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/tornado/websocket.py", line 293, in on_connection_close
    self.on_close()
  File "/usr/local/lib/python2.7/site-packages/IPython/html/services/kernels/handlers.py", line 131, in on_close
    if self.kernel_id in km:
AttributeError: 'IOPubHandler' object has no attribute 'kernel_id'
2014-03-20 11:30:48.775 [NotebookApp] WARNING | Cross Origin WebSocket Attempt.
2014-03-20 11:30:48.775 [tornado.application] ERROR | Uncaught exception in /kernels/1dda8602-2f19-474b-8eac-49508feca422/shell
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/tornado/websocket.py", line 322, in wrapper
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/IPython/html/base/zmqhandlers.py", line 114, in open
    raise web.HTTPError(404)
HTTPError: HTTP 404: Not Found

Steps to reproduce the problem

  1. Start notebook server
  2. M-x ein:notebooklist-open
  3. Open any notebook (new or previously saved, doesn't matter)
  4. Errors start in the Terminal right away

Expected output

Should be able to execute cells...

Your EIN configuration (in .emacs.d/init.el or somewhere else)

Installed from el-get. Just usting the basic (require 'ein)

Your IPython configuration

  1. What is your IPython version? (run ipython --version): 1.2.1
  2. How do you start IPython? (e.g., ipython notebook --port 9999): ipython notebook --port 8555
  3. What is your IPython notebook port number or URL?:ahttp://127.0.0.1:8555/

Additional information (if any)

System info:

("EIN system info"
 :emacs-version
 "GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2013-03-12 on bob.porkrind.org"
 :emacs-bzr-version nil
 :window-system ns
 :emacs-variant nil
 :os
 (:uname
  "Darwin Eriks-MacBook-Air.local 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
"
  :lsb-release nil)
 :image-types
 (png gif tiff jpeg xpm xbm pbm)
 :image-types-available
 (png gif tiff jpeg xpm xbm pbm)
 :request
 (:backend curl)
 :ein
 (:version "0.2.1alpha2.d62dc59-dirty"
       :source-dir "/Users/erik/.emacs.d/el-get/ein/lisp/")
 :lib
 ((:name "websocket"
     :path "~/.emacs.d/el-get/websocket/websocket.elc"
     :featurep t
     :version-var websocket-version
     :version "1.1")
  (:name "request"
     :path "~/.emacs.d/el-get/request/request.elc"
     :featurep t
     :version-var request-version
     :version "0.2.0")
  (:name "auto-complete"
     :path "~/.emacs.d/el-get/auto-complete/auto-complete.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "auto-complete"
     :path "~/.emacs.d/el-get/auto-complete/auto-complete.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "popup"
     :path "~/.emacs.d/el-get/popup/popup.elc"
     :featurep t
     :version-var popup-version
     :version "0.5.0")
  (:name "fuzzy"
     :path "~/.emacs.d/el-get/fuzzy/fuzzy.elc"
     :featurep nil
     :version-var nil
     :version nil)
  (:name "python"
     :path "/Applications/Emacs.app/Contents/Resources/lisp/progmodes/python.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "helm"
     :path "~/.emacs.d/el-get/helm/helm.el"
     :featurep t
     :version-var nil
     :version nil)))
shackra commented 10 years ago

This happens with GNU Emacs as well...

sdague commented 10 years ago

This seems to be true of 1.2.1 on Linux as well. If I pip install ipython 1.1 ein works again.

shackra commented 10 years ago

indeed, it works if I downgrade ipython to 1.1!

tsmithe commented 10 years ago

This is true given the default package versions in the new Ubuntu LTS release, so it's quite problematic..

weissjeffm commented 10 years ago

Up until today, I was able to use ipython 1.0 successfully with ein, anything >1.1 had this websocket error. Now I get this same error with every version, including 1.0 and 1.1.

rgbkrk commented 10 years ago

You're opening yourself up to a remote execution vulnerability if you're using IPython 1.1.

The right way for this plugin to work is to actually communicate with an IPython kernel, in the same manner that @ivanov's vim plugin does. Exposing your websockets is not a good idea.

gcr commented 10 years ago

Heads up! Websocket.el fixes this issue in https://github.com/ahyatt/emacs-websocket/pull/35 by not sending an origin header. Does using that version of websockets work for you?