Wait; I was confused. Ignore what I said in the above paragraph; you
were doing things correctly with /eval.
For version 2 of the server, it goes like this:
POST or GET request
aleph2.sagemath.org/kernel, with a custom HTTP header of
Accept: application/json
That will return a JSON dictionary that looks like this:
{"kernel_id": "ce20fada-f757-45e5-92fa-05e952dd9c87", "ws_url":
"ws://localhost:8888/"}
Then open up websocket channels to the two URLs:
shell channel: <ws_url>/kernel/<kernel_id>/shell
iopub channel: <ws_url>/kernel/<kernel_id>/iopub
Then send an execute_request message on the shell channel, following the
ipython format [1].
Then listen on the iopub channel for messages until you get a kernel
status idle message, and also listen on the shell channel until you get
an execute_reply message.
You'll get a kernel dead message on the iopub channel when the cell
times out. If you don't have interacts, it will time out pretty much
immediately. If you do have interacts, then the timeout is something 30
or 60 seconds between execute_requests.
I put up a short client illustrating this at
https://github.com/sagemath/sagecell/blob/master/contrib/sagecell-client/sagecell-client.py
(requires the python websocket-client package to be installed).
Also, we changed interact messages to be more standard IPython messages.
They are no longer "interact_prepare" messages, but instead come as
"display_data" messages with a mime type of "application/sage-interact".
Thanks,
Jason
[1]
http://ipython.org/ipython-doc/dev/development/messaging.html#execute