Satoshi Forum Archive
Thread #0128

bitcoind not responding to RPC

mtgox2010-07-23T12:29:48Z

Occasionally bitcoind will not respond to RPC I'm calling it from php and I get this error:
Warning: fopen(http://127.0.0.1:8332) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
It happens a lot locally on my windows machine and less frequently on my linux server.
Anyone else have this problem?

Original message

The Madhatter2010-07-23T16:23:16Z

Try taking the "http://" out of your fsockopen(). The JSON-RPC server isn't really HTTP.
I've had the best luck with the curl+json php extensions, myself.

Original message

mtgox2010-07-23T16:25:59Z

Well it works 95% of the time which is what is weird

Original message

The Madhatter2010-07-23T16:39:00Z

Strange. I use my bitcoind almost every day from PHP, and I haven't encountered that.

Original message

mtgox2010-07-23T16:47:36Z

I also get it anytime I send an invalid bitcoin address. Which is weird since it doesn't seem like that would effect the connecting.

Original message

satoshi2010-07-23T17:23:47Z

If I recall correctly, 500 is the prescribed status code for JSON-RPC error responses. There is still a JSON response in the body of the reply telling the explanation of the error, which could be something like {"result":"","error":"bitcoin address not found","id":"1"}.

Original message

mtgox2010-07-23T18:14:48Z

Weird I guess fopen() in php dies if the response is 500?
It seems like errors such as invalid address should just be normal replies just not "sent" so we can just check the reply string. I think of 500 errors as the server itself having an error.

Original message

satoshi2010-07-24T01:15:58Z

Can anyone confirm if JSON-RPC over HTTP is supposed to use status 500 if the reply is an error reply? I can't remember where I picked that up, maybe it's wrong. It seems like 200 would make more sense unless there's something wrong with the mechanics of the HTTP request itself. (and maybe that's what it said and I forgot and spread 500 to all error responses)

Original message