Ngọc Thạch
Ngọc Thạch

Reputation: 27

bitcoind with jsonRPCClient.php not working

i have a problem when use jsonRPCClient to get info bitcoin on my vps ubuntu, and i dont'n know how can fix it.

<?php
require_once 'jsonRPCClient.php';
$bitcoin = new jsonRPCClient('http://user:[email protected]:8332/');
echo "<pre>\n";
print_r($bitcoin->getinfo());
echo "</pre>";
?>

my config:

server=1
rpcuser=username
rpcpassword=pass123
rpcallowip=127.0.0.1
daemon=1

it has error:

    Warning:  fopen(http://[email protected]:8332/): failed to open stream: Connection refused in /var/www/.../jsonRPCClient.php on line 133

    Fatal error:  Uncaught exception 'Exception' with message 'Unable to connect to http://user:[email protected]:8332/' in /var/www/.../jsonRPCClient.php:141
    Stack trace:
    #0 /var/www/.../common.php(15): jsonRPCClient->__call('getinfo', Array)
    #1 /var/www/.../common.php(15): jsonRPCClient->getinfo()
    #2 /var/www/.../index.php(3): include('/var/www/coinba...')
    #3 {main}

  thrown in /var/www/.../jsonRPCClient.php on line 141

how to fix it, help me, please!!!

Upvotes: 1

Views: 2494

Answers (1)

m1xolyd1an
m1xolyd1an

Reputation: 535

It would appear your username and password do not match you bitcoin.conf file.

rpcuser=username
rpcpassword=pass123

('http://user:[email protected]:8332/');

It can be difficult to debug with jsonRPCclient for this exact reason. The jsonRPCClient library uses fopen() and will throw an exception saying "Unable to connect" if it receives a 404 or 500 error from bitcoind. This prevents you from being able to see error messages generated by bitcoind.

Also it is recommended to use easybitcoin library instead of jsonRPCClient.

Source

Instead, follow the above link, use the easybitcoin.php library, and give this a try.

require("easybitcoin.php");
$bitcoin = new Bitcoin("username", "pass123");

$info = $bitcoin->getinfo();
print_r($info);

Upvotes: -3

Related Questions