Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: coinableS on December 26, 2015, 08:10:00 AM



Title: JSON RPC PHP
Post by: coinableS on December 26, 2015, 08:10:00 AM
Can't figure out what I'm doing wrong.
I'm trying to access my node running on my computer via my webserver.
Keep getting the same error.

Code:
Fatal error:  Uncaught exception 'Exception' with message 'Incorrect response id (request id: 1, response id: )' in /home/site/public_html/jsonRPCClient.php:152
Stack trace:
#0 /home/site/public_html/node.php(8): jsonRPCClient->__call('getinfo', Array)
#1 /home/site/public_html/node.php(8): jsonRPCClient->getinfo()
#2 {main}
  thrown in /home/site/public_html/jsonRPCClient.php on line 152

I've searched, and have found similar threads with the same error as me, but no clear fix.
Put my webserver as rpcallowip...

my bitcoin.conf
Code:
server=1
rpcuser=userRPC
rpcpassword=passRPC
rpctimeout=30
rpcallowip=68.65.122.148
rpcport=8332

test code
Code:
<?php

  require_once 
'jsonRPCClient.php';
 
  
$btc= new jsonRPCClient('http://userRPC:passRPC@68.105.12.345:8332/');
 
  echo 
"<pre>\n";
  
print_r($btc->getinfo());
  echo 
"</pre>";

?>


Does it matter if I launch bitcoin core, vs bitcoind.exe since I put server=1 in my conf? I've tried launching both, they both do the same thing. I even receive the exact same error if I close my node down, so I'm clearly have an issue connecting.  Bitcoind.exe doesn't do anything, it opens a command window, but there's no text or anything going on to confirm it's working... is that normal?


Title: Re: JSON RPC PHP
Post by: micaman on December 27, 2015, 04:06:53 PM
If you are running both the node and the webserver on the same machine, you can try to troubleshoot by changing the IPs to 127.0.0.1. If it works you might have port-forwarding issues or forgot to configure them.
You can also just try http://68.105.12.345:8332/ or http://127.0.0.1:8332/ in case you change it, on your browser to test connectivity, if working correctly, it should prompt you with a login form.


Title: Re: JSON RPC PHP
Post by: MrCrank on July 02, 2017, 02:14:09 PM
I have issue too.

my code not work and i can't see errors..

where I can download jsonRPCClient.php ?

I checked server error.log:
Code:
PHP Fatal error:  Class 'jsonRPCClient' not found in /var/www/html/index.php on line 4

but I use include_once('jsonRPCClient.php');

Thanks.

 


Title: Re: JSON RPC PHP
Post by: Euro1000 on July 02, 2017, 02:29:17 PM
Did you already made a test on the RPC conncetion beside using PHP.
In order to test the RPC connection itself you can just send a test message via the Firefox Addin HttpRequester.

There is also curl (a command line tool) but it was not working for me.


Title: Re: JSON RPC PHP
Post by: micaman on July 02, 2017, 02:35:28 PM
I have issue too.

my code not work and i can't see errors..

where I can download jsonRPCClient.php ?

I checked server error.log:
Code:
PHP Fatal error:  Class 'jsonRPCClient' not found in /var/www/html/index.php on line 4

but I use include_once('jsonRPCClient.php');

Thanks.

 

The link available at https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP doesn't seem to be working.
You can try with EasyBitcoin-PHP available at https://github.com/aceat64/EasyBitcoin-PHP


Title: Re: JSON RPC PHP
Post by: MrCrank on July 02, 2017, 03:05:48 PM
The link available at https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP doesn't seem to be working.
You can try with EasyBitcoin-PHP available at https://github.com/aceat64/EasyBitcoin-PHP

I have read it. I thought that my server wrong configuration..
But I don't understand why jsonRPCClient.php not work?

Ok. I try EasyBitcoin-PHP and this is works now.
Thanks!