Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: entertheabyss on August 16, 2014, 06:00:27 AM



Title: jsonrpc [solved]
Post by: entertheabyss on August 16, 2014, 06:00:27 AM
i tried running the basic getinfo script
Quote
<?php
  require_once 'jsonRPCClient.php';
 
  $bitcoin = new jsonRPCClient('http://user:password@127.0.0.1:8332/');
 
  echo "<pre>\n";
  print_r($bitcoin->getinfo());
  echo "</pre>";
?>

I get error:

Quote
PHP Warning:  fopen(http://...@127.0.0.1:8332/): failed to open stream: Connection refused in .../jsonRPCClient.php on line 132
PHP Fatal error:  Uncaught exception 'Exception' with message 'Unable to connect to http://user:password@127.0.0.1:8332/' in .../jsonRPCClient.php:140
Stack trace:
#0 ...bitcoingetinfo.php(9): jsonRPCClient->__call('getinfo', Array)
#1 .../getinfo.php(9): jsonRPCClient->getinfo()
#2 {main}
  thrown in .../jsonRPCClient.php on line 140

What am I doing wrong?

*solved*


Title: Re: jsonrpc
Post by: dhenson on August 16, 2014, 06:06:43 AM
Are you sure bitcoind is fully installed and running?

https://en.bitcoin.it/wiki/PHP_developer_intro


Title: Re: jsonrpc
Post by: entertheabyss on August 16, 2014, 06:20:34 AM
yes. I can run  

Quote
$ ./bitcoind getinfo

in the command line

it just doesnt work inside of a php script


Title: Re: jsonrpc
Post by: dhenson on August 16, 2014, 06:44:19 AM
Shot in the dark, but might the connection be being blocked by firewall software on your PC?

edit... It's been forever for me, but I think you need to specify your bitcoind user and pass in a text file somewhere.

found it... ~/.bitcoin/bitcoin.conf


Title: Re: jsonrpc
Post by: entertheabyss on August 16, 2014, 07:04:12 AM
Shot in the dark, but might the connection be being blocked by firewall software on your PC?

edit... It's been forever for me, but I think you need to specify your bitcoind user and pass in a text file somewhere.

found it... ~/.bitcoin/bitcoin.conf

i already set rpcuser and rpcpassword in the .conf


Title: Re: jsonrpc
Post by: dhenson on August 16, 2014, 07:11:04 AM
If you can telnet into port 8332 (proving a firewall isn't blocking it) and you've already double checked your .conf for errors then I'm coming up blank.


Title: Re: jsonrpc
Post by: entertheabyss on August 16, 2014, 07:28:11 AM
If you can telnet into port 8332 (proving a firewall isn't blocking it) and you've already double checked your .conf for errors then I'm coming up blank.

when I run
Quote
sudo telnet localhost 8332

I get.

Quote
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

What do i do now?


Title: Re: jsonrpc
Post by: Jouke on August 16, 2014, 09:34:19 AM
bitcoin config: rpcallowip


Title: Re: jsonrpc
Post by: entertheabyss on August 16, 2014, 04:14:11 PM
bitcoin config: rpcallowip


I get:

Quote
EXCEPTION: N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_15program_op tions14invalid_syntaxEEEEE      
unrecognized line in 'rpcallowip'      

I tried.
Quote
rpcallowip=true
I get no errors from bitcoind.

Unfortunately the error is persists. What else should I try?


Title: Re: jsonrpc
Post by: kjj on August 16, 2014, 04:28:21 PM
server=1


Title: Re: jsonrpc
Post by: entertheabyss on August 16, 2014, 04:53:53 PM
I figured it out. I was using an altcoind client but i was binding to the bitcoin port. Thank you for your assistance. This issue is solved.