skeeto / elisp-json-rpc

JSON-RPC library for Emacs Lisp
The Unlicense
40 stars 9 forks source link

Add author headers for Melpa compatibility. #3

Closed proofit404 closed 10 years ago

skeeto commented 10 years ago

Thanks! I removed the copyright notice since it's public domain, and then merged it as 2cae684.

proofit404 commented 10 years ago

Thanks for that awesome package.

skeeto commented 10 years ago

By the way, I'm curious why you wanted to put this in MELPA. Have you made something that depends on it?

proofit404 commented 10 years ago

Currently we work on feature/json-rpc branch of my anaconda-mode project. We use your library at the emacs lisp client side.

proofit404 commented 10 years ago

Can you help me with some debugging? For example I have following code:

(apply 'json-rpc anaconda-mode-connection command args)

When I run it with any args it just hold my emacs. Edebug session says it die on (process-buffer (json-rpc-process connection) in json-rpc-wait function trying to switch in killed (connection) buffer. May it be caused by some keep-alive option? Can you provide some minimum server example appropriate for debugging? All code available at my github profile client, server.

fbergroth commented 10 years ago

@proofit404 it blocks because content-length header is not sent in the response.

Try adding self.send_header("Content-Length", len(response)).

skeeto commented 10 years ago

@fbergroth Exactly right.

You really want to be using HTTP/1.1 anyway so that every request doesn't require a new TCP connection. json-rpc re-uses the same TCP connection until the server cuts it off (then it reconnects automatically when needed).

However, I'd still like to add support for HTTP/1.0 and read whatever's left after the connection closes. It will make problems like this less confusing in the future. Could you give me an example of a valid RPC call for your server? I thought this would work, but I'm getting a 400 no matter what I try.

{"jsonrpc":"2.0","method":"complete","params":["len", 1, 1, ""],"id":0}

Also, on Linux your server doesn't use carriage returns as required. I'm relaxing json-rpc's header parsing so this won't be a problem.

proofit404 commented 10 years ago

Thank you guys!