Re: JSON-RPC Multiple Invocations

I noticed from a hint that Satoshi dropped in the JSON-RPC password thread about so-called “Multiple Invocation” support in Bitcoin’s JSON-RPC.

As I run a site that polls bitcoind for payments to a large number of addresses twice a minute, I was intrigued. First of all, this isn’t JSON-RPC 2.0’s “Batch” support, where requests are submitted in an array and responses are received the same way […]

As you can see, the server replies with two complete HTTP 200 responses instead of (as I would have expected) one response with the two lines concatenated as I did in the request.

I can’t figure out how to parse that with anything at all semi-automated in Python. urllib2 and httplib both return after the first response and drop the second one on the floor.

Has anyone encountered this problem before? Does anyone know of a Python library that can handle this strange multi-request behaviour?

Obviously it’s a bug that it repeats the header.

I was trying to follow the 1.0 spec: http://json-rpc.org/wiki/specification   It called for multiple invocation.

I think they mean it’s like this, but I’m not sure:

Post:
{“method”: “postMessage”, “params”: [“Hello all!”], “id”: 99}
{“method”: “postMessage”, “params”: [“I have a question:”], “id”: 101}

Reply:
{“result”: 1, “error”: null, “id”: 99}
{“result”: 1, “error”: null, “id”: 101}

I can’t remember where I think I saw that it’s supposed to send back HTTP status 500 for an error reply.  If it contains multiple responses and one is an error, I wonder if that makes the status 500 for the whole thing, I guess so.  Maybe it should always return 200.  I think someone sounded like the 500 might be causing a problem.

This probably gets fixed after 0.3.3.  Until then, just use single invocation.  I wonder if any JSON-RPC package even supports multiple invocation, probably not.

It would be nice if we could pin down better how multiple-invocation is supposed to work, if at all, before trying to fix it, and whether returning HTTP status 500 for error response is right.

30,651 total views, 14 views today

https://bitcointalk.org/index.php?topic=528.msg5416#msg5416