Bitcoin Forum
August 21, 2018, 06:58:08 PM *
News: Latest stable version of Bitcoin Core: 0.16.2  [Torrent].
   Home   Help Search Donate Login Register  
Pages: [1]
Author Topic: PHP JSON-RPC connection problems while sending BTC [SOLUTION]  (Read 1622 times)
Offline Offline

Activity: 1
Merit: 0

View Profile
July 14, 2011, 02:55:28 PM

Hi, I'm russian PHP developer, now working with Bitcoin local server.

On the official wiki (, connection with bitcoind server realised through JSON-RPC class for PHP.

It works, it can connect to the server and get info, balance etc. But if some error happens on the server side or any message should be forced in answer JSON-RPC class died.

The reason is: "Couldn't connect to server". It is very strange, that in first line of code you succefully getting info, but in the second line you couldn't connect while trying to send bitcoins to address.

I found the same problem discussing on this forum( and other forums, but no solution was reached.

But the solution of this problem is easy. JSON-RPC class uses function fopen to connect to the server. That's bad, because in case of server want to send some information instead of good status, it sends it with status header 500 [Internal Server Error] and function fopen dies.

Post data: {"method":"sendtoaddress","params":["************ejLDXo65y98XfS3aj4MauH8",1.00000000,"dsfa","ghfhfg"],"id":1}

HTTP/1.1 500 Internal Server Error
Date: Thu, 14 Jul 2011 14:31:34 +0000
Connection: close
Content-Length: 196
Content-Type: application/json
Server: bitcoin-json-rpc/0.3.23-beta

{"result":null,"error":{"code":-4,"message":"Error: This transaction requires a transaction fee of at least 0.0005 because of its amount, complexity, or use of recently received funds  "},"id":1}

Function fopen can't parse this result and returns an error. Everything you need is to use cURL or Socket functions instead of fopen. Here i found a script that just like JSON-RPC but works through cURL (

I will be very glad if this information will help someone.

Question to moderators: what should i do to become an "establish" user ?Smiley
Pages: [1]
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!