Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Url encoding error gives a 404 for ein:notebooklist-open #8

Closed
commandodev opened this issue Jul 2, 2012 · 20 comments
Closed

Url encoding error gives a 404 for ein:notebooklist-open #8

commandodev opened this issue Jul 2, 2012 · 20 comments
Labels

Comments

@commandodev
Copy link

In emacs using

python zeroein/zeroein.py --emacs `which emacs-snapshot`

I get this:

Contacting host: 127.0.0.1:8888
ein: [error] Error (error) while opening notebook list at the server 8888.
Contacting host: 127.0.0.1:8888

The terminal running ipython notebook reports

WARNING:root:404 GET /notebooks%3f_%3d1341211357 (127.0.0.1) 0.43ms

Interestingly if I decode the url and go to http://127.0.0.1:8888/notebooks?_=1341211357 in my browser I get the json response that I assume ein is expecting:

[{"name":"test","notebook_id":"1c7fc74f-4037-4f47-823e-ef6fbea4d5c9"}]

emacs version: GNU Emacs 24.1.50.1
ipython version: 0.13.dev

@tkf
Copy link
Owner

tkf commented Jul 2, 2012

Thanks for the report. It looks like your Emacs encoded URL before sending it somehow. In my IPython server log I've never seen %3f_%3d; I have ?_= instead.

Could you try this and see if you can get JSON and you have similar log message in the terminal?

(url-retrieve "http://127.0.0.1:8888/notebooks?_=1341211357"
              (lambda (&rest ignore) (pop-to-buffer (current-buffer))))

BTW, what is your OS? I don't know it is relevant, but just checking.

@commandodev
Copy link
Author

That snippet worked fine, I got the headers and expected JSON in the buffer.

I'm on Ubuntu and the emacs-snapshot comes from a PPA

@tkf
Copy link
Owner

tkf commented Jul 2, 2012

Could you paste the result of the following also? An easiest way to do it is type M-:, paste the code in the minibuffer and then fetch the result in the *Message* buffer.

(url-generic-parse-url "http://127.0.0.1:8888/notebooks?_=1341211357")

In my Emacs, I've got:

[cl-struct-url "http" nil nil "127.0.0.1" 8888 "/notebooks?_=1341211357" nil nil t nil t]

@commandodev
Copy link
Author

Exactly the same for me:

[cl-struct-url "http" nil nil "127.0.0.1" 8888 "/notebooks?_=1341211357" nil nil t nil t]

@tkf
Copy link
Owner

tkf commented Jul 2, 2012

That's very strange... Can you execute (ein:log-set-level 'debug) before ein:notebooklist-open, go to the *ein:log-all* buffer (it starts with a space), and paste the whole buffer (or just the line(s) starting with "Start querying:" if it is too big)?

@commandodev
Copy link
Author

Here's everything:

[error] Error (error) while opening notebook list at the server 8888. @#<buffer *Messages*>
[debug] EIN:QUERY-AJAX @#<buffer *scratch*>
[debug] Start querying: http://127.0.0.1:8888/notebooks?_=1341215532 @#<buffer *scratch*>
[debug] Start timer: timeout=1000 ms @#<buffer *scratch*>
[debug] EIN:QUERY-AJAX-CALLBACK @#<buffer  *http 127.0.0.1:8888*>
[debug] status = (:error ...) @#<buffer  *http 127.0.0.1:8888*>
[debug] url-http-response-status = 404 @#<buffer  *http 127.0.0.1:8888*>
[debug] (buffer-string) =
HTTP/1.1 404 Not Found
Content-Length: 69
Content-Type: text/html; charset=UTF-8
Server: TornadoServer/2.2

<html><title>404: Not Found</title><body>404: Not Found</body></html> @#<buffer  *http 127.0.0.1:8888*>
[debug] EIN:QUERY-AJAX-CANCEL-TIMER @#<buffer  *http 127.0.0.1:8888*>
[debug] data = nil @#<buffer *Messages*>
[debug] canceled = nil @#<buffer *Messages*>
[debug] Executing success/error callback. @#<buffer *Messages*>
[error] Error (error) while opening notebook list at the server 8888. @#<buffer *Messages*>
[debug] Executing status-code callback. @#<buffer *Messages*>
[debug] EIN:QUERY-AJAX @#<buffer *ein:notebooklist 8888*>
[debug] Start querying: http://127.0.0.1:8888/notebooks?_=1341215549 @#<buffer *ein:notebooklist 8888*>
[debug] Start timer: timeout=1000 ms @#<buffer *ein:notebooklist 8888*>
[debug] EIN:QUERY-AJAX-CALLBACK @#<buffer  *http 127.0.0.1:8888*>
[debug] status = (:error ...) @#<buffer  *http 127.0.0.1:8888*>
[debug] url-http-response-status = 404 @#<buffer  *http 127.0.0.1:8888*>
[debug] (buffer-string) =
HTTP/1.1 404 Not Found
Content-Length: 69
Content-Type: text/html; charset=UTF-8
Server: TornadoServer/2.2

<html><title>404: Not Found</title><body>404: Not Found</body></html> @#<buffer  *http 127.0.0.1:8888*>
[debug] EIN:QUERY-AJAX-CANCEL-TIMER @#<buffer  *http 127.0.0.1:8888*>
[debug] data = nil @#<buffer *scratch*>
[debug] canceled = nil @#<buffer *scratch*>
[debug] Executing success/error callback. @#<buffer *scratch*>
[error] Error (error) while opening notebook list at the server 8888. @#<buffer *scratch*>
[debug] Executing status-code callback. @#<buffer *scratch*>
[debug] EIN:QUERY-AJAX @#<buffer *scratch*>
[debug] Start querying: http://127.0.0.1:8888/notebooks?_=1341215594 @#<buffer *scratch*>
[debug] Start timer: timeout=1000 ms @#<buffer *scratch*>
[debug] EIN:QUERY-AJAX-CALLBACK @#<buffer  *http 127.0.0.1:8888*>
[debug] status = (:error ...) @#<buffer  *http 127.0.0.1:8888*>
[debug] url-http-response-status = 404 @#<buffer  *http 127.0.0.1:8888*>
[debug] (buffer-string) =
HTTP/1.1 404 Not Found
Content-Length: 69
Content-Type: text/html; charset=UTF-8
Server: TornadoServer/2.2

<html><title>404: Not Found</title><body>404: Not Found</body></html> @#<buffer  *http 127.0.0.1:8888*>
[debug] EIN:QUERY-AJAX-CANCEL-TIMER @#<buffer  *http 127.0.0.1:8888*>
[debug] data = nil @#<buffer *ein:notebooklist 8888*>
[debug] canceled = nil @#<buffer *ein:notebooklist 8888*>
[debug] Executing success/error callback. @#<buffer *ein:notebooklist 8888*>
[error] Error (error) while opening notebook list at the server 8888. @#<buffer *ein:notebooklist 8888*>
[debug] Executing status-code callback. @#<buffer *ein:notebooklist 8888*>

Perhaps my emacs is loading a different version of the library that does the http requesting?

@tkf
Copy link
Owner

tkf commented Jul 2, 2012

Thanks for trying. From the log, it looks like EIN does its job. I have no idea why the URL is encoded. Did you try ein:notebooklist-open several times repeatedly (Just in case. Because it fails sometimes before succeeds)?

I think the library (url.el) is fine. I am using emacs-snapshot from PPA in Ubuntu 10.10 and 11.10, so I think your Emacs environment is very close to mine. But I've never seen that URL encoding failure. I do get 404 sometimes but I can connect to the server after retrying several times (http://tkf.github.com/emacs-ipython-notebook/#url-retrieve).

I think the fix in long-run is to add another backend for querying other than url-retrieve, such as wget or curl. But it will take sometime to implement.

@commandodev
Copy link
Author

Yes, very curious!

I tried multiple times as you suggested (both with M-x and in the scratch buffer) and it's the same every time. I will try and do the manual install or install it with el-get.

I also tried it with the built in emacs 23.3.1 and I got the following, now sure if it's relevant or not:

Loading /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/autostart.el (source)...
Nxml/Nxhtml Autostart.el loading ...
Loading /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/etc/schema/schema-path-patch.el (source)...done
... loading web-autoload
Loading /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/web-autoload.el (source)...done
... nXhtml loading 0.1 seconds elapsed ...
Loading /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/nxhtml-loaddefs.el (source)...done
... nXhtml loading 0.9 seconds elapsed ...
Turn on `nxhtml-menu-mode' unconditionally
Tested for Bug 3467 => FAILED
... nXhtml loading 2.9 seconds elapsed ...
Loading vc-git...done
Patching xhtml-loader.rnc
Wrote /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/etc/schema/xhtml-loader.rnc
... nXhtml loading 2.9 seconds elapsed ...
Loading /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/nxhtml/nxhtml-autoload.el (source)...
majmodpri-apply-priorities running ... (done)
majmodpri-apply-priorities running ... (done)
Loading /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/nxhtml/nxhtml-autoload.el (source)...done
... nXhtml loading 3.0 seconds elapsed ...
=== Loaded at nxhtml/autostart.el end:
(feature 'html-imenu)=t
(feature 'html-pagetoc)=t
(feature 'html-quote)=t
(feature 'html-site)=t
(feature 'html-toc)=t
(feature 'html-upl)=t
(feature 'inlimg)=t
(feature 'mumamo)=t
(feature 'nxhtml-menu)=t
(feature 'nxhtml-mode)=t
(feature 'rngalt)=t
(feature 'tidy-xhtml)=t
(feature 'xhtml-help)=t
Nxml/Nxhtml Autostart.el loaded in 3.0 seconds
trace: loading flymake-files
Loading /home/SOLAISE/bford/dev/ve/ticket-manager/src/zeroein/nxhtml/autostart.el (source)...done
load-with-code-conversion: Arithmetic overflow error: "4294967296"
Quit
byte-code: Beginning of buffer [3 times]

@tkf
Copy link
Owner

tkf commented Jul 2, 2012

Just to clarify, you always got encoding error in the IPython log, right? I think it should be possible to fix the problem because directly invoking url-retrieve has no problem, but I have no idea now.

Also in my Emacs 23.3.1 it just works. Really strange. If emacs -q -l nxhtml/autostart.el does not work, it could be a bug in nxhtml. A quick workaround could be to replace (add-to-list 'load-path (zeroein:path "nxhtml" "util")) with (load (zeroein:path "nxhtml" "autostart.el")) in zeroein.el.

@epatters
Copy link

epatters commented Jul 4, 2012

I think I am experiencing the same problem (Emacs 23.4.1). Here is the output in **Messages** after running zeroein.py:

For information about GNU Emacs and the GNU system, type C-h C-a.
Loading /home/epatters/local/zeroein/nxhtml/autostart.el (source)...
Nxml/Nxhtml Autostart.el loading ...
Loading /home/epatters/local/zeroein/nxhtml/etc/schema/schema-path-patch.el (source)...done
... loading web-autoload
Loading /home/epatters/local/zeroein/nxhtml/web-autoload.el (source)...done
... nXhtml loading 0.1 seconds elapsed ...
Loading /home/epatters/local/zeroein/nxhtml/nxhtml-loaddefs.el (source)...done
... nXhtml loading 2.2 seconds elapsed ...
Turn on `nxhtml-menu-mode' unconditionally
Tested for Bug 3467 => FAILED
... nXhtml loading 6.3 seconds elapsed ...
(New file)
Loading vc-git...done
xhtml-loader.rnc was ok
Wrote /home/epatters/local/zeroein/nxhtml/etc/schema/xhtml-loader.rnc
... nXhtml loading 6.4 seconds elapsed ...
Loading /home/epatters/local/zeroein/nxhtml/nxhtml/nxhtml-autoload.el (source)...
majmodpri-apply-priorities running ... (done)
majmodpri-apply-priorities running ... (done)
Loading /home/epatters/local/zeroein/nxhtml/nxhtml/nxhtml-autoload.el (source)...done
... nXhtml loading 6.9 seconds elapsed ...
=== Loaded at nxhtml/autostart.el end:
(feature 'html-imenu)=t
(feature 'html-pagetoc)=t
(feature 'html-quote)=t
(feature 'html-site)=t
(feature 'html-toc)=t
(feature 'html-upl)=t
(feature 'inlimg)=t
(feature 'mumamo)=t
(feature 'nxhtml-menu)=t
(feature 'nxhtml-mode)=t
(feature 'rngalt)=t
(feature 'tidy-xhtml)=t
(feature 'xhtml-help)=t
Nxml/Nxhtml Autostart.el loaded in 7.0 seconds
trace: loading flymake-files
Loading /home/epatters/local/zeroein/nxhtml/autostart.el (source)...done
load-with-code-conversion: Arithmetic overflow error: "4294967296"
byte-code: Beginning of buffer [4 times]
byte-code: End of buffer
byte-code: Beginning of buffer

Note that running emacs -q -l nxhtml/autostart.el does work.

@tkf
Copy link
Owner

tkf commented Jul 4, 2012

Running zeroein.py is equivalent to emacs -Q -l zeroein.el -f ein:notebooklist-open once it fetched all other modules. Probably using -q instead of -Q is better? What happens when emacs -q -l nxhtml/autostart.el? Well, I guess that's not the reason, but that's the only different I can see.

BTW, I found 4294967296 only in websocket.el under zeroein repository. What happens when you do emacs -q -l websocket/websocket.el?

@epatters
Copy link

epatters commented Jul 4, 2012

I think you've found the source of the problem. Running emacs -q -l websocket/websocket.el results in the error:

load-with-code-conversion: Arithmetic overflow error: "4294967296"

@epatters
Copy link

epatters commented Jul 4, 2012

My elisp is very weak, but I don't see how the function websocket-to-bytes in websocket.el could possibly work on a 32-bit system. It uses the constant 2**32 = 4294967296, but on my system most-positive-fixnum is 2**29 - 1 = 536870911.

@tkf
Copy link
Owner

tkf commented Jul 4, 2012

Could you report the problem in websocket.el's issue tracker?
https://github.com/ahyatt/emacs-websocket/issues/new
I think it's better if somebody who can reproduce the problem can report the problem.

Strangely, I can load websocket.el even though my most-positive-fixnum is same as yours (536870911).

@tkf
Copy link
Owner

tkf commented Jul 4, 2012

Don't worry about the report. I found a related problem so I just posted it in the websocket.el tracker (ahyatt/emacs-websocket#18). If you can add some more details, please do it.

@tkf
Copy link
Owner

tkf commented Jul 17, 2012

@Boothead If you are still interested in trying EIN in Emacs 24, probably the following code helps you:

(defadvice ein:url-no-cache
  (around ein:url-no-cache-no (url) activate)
  "Do not use jQuery-like caching workaround."
  (setq ad-return-value url))

I use jQuery-like way to disable caching because EIN's core is simple translation of browser based frontend. But from reading url.el's manual, there is no need to do that unless you have url-automatic-caching set to non-nil. I won't remove ein:url-no-cache, unless I am sure that it is not needed, but you can try it out with the above code before it is officially in.

@commandodev
Copy link
Author

@tkf Sorry for the long delay - I only just noticed this reply. The defadvice snippet you gave here worked fine for me. Thanks a lot!

@tkf
Copy link
Owner

tkf commented Sep 18, 2012

Don't worry. I am glad the notification was not lost :) So, I guess it's better to remove ein:url-no-cache. I will let you know once it's done.

@tkf
Copy link
Owner

tkf commented Jan 10, 2013

This should be fixed by #95.

@tkf
Copy link
Owner

tkf commented Jan 17, 2013

#95 is merged. Check the master.

@tkf tkf closed this as completed Jan 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants