Bitcoin Forum

Economy => Services => Topic started by: Vortex20000 on February 25, 2015, 01:01:39 AM



Title: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: Vortex20000 on February 25, 2015, 01:01:39 AM
Hullo!

I've had some problems getting a PHP script using jsonRPCClient to connect to a running bitcoind daemon on another, external server. My bitcoin.conf currently looks like this:

Code:
server=1
daemon=1
listen=1
rpcuser=username
rpcpassword=password
rpcallowip=IP.OF.WEB.SERVER
rpcport=8332

The PHP script is something like this:

Code:
<?php

require 'jsonRPCClient.php';

$btc = new jsonRPCClient("http://username:password@host:8332/");
print_r($btc->getinfo());

?>


Debug shows error occurs when jsonRPCClient tries to connect to the server. Either a "Connection timed out." or "Connection refused." error.

Bounty goes to the first person to give me a working solution to this problem.

Solutions I've Tried

Open all ports on netstat. Nope. All open. VPS hoster is not blocking any ports their side.

Is it listening? Yup, it is, so this shouldn't be a problem.

Code:
netstat -nlp | grep 8332
tcp6       0      0 :::8332                 :::*                    LISTEN      19482/bitcoind



Title: Re: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: yogg on February 25, 2015, 01:12:46 AM
Hullo!

I've had some problems getting a PHP script using jsonRPCClient to connect to a running bitcoind daemon on another, external server. My bitcoin.conf currently looks like this:

Code:
server=1
daemon=1
listen=1
rpcuser=username
rpcpassword=password
rpcallowip=IP.OF.WEB.SERVER
rpcport=8332

The PHP script is something like this:

Code:
<?php

require 'jsonRPCClient.php';

$btc = new jsonRPCClient("http://username:password@host:8332/");
print_r($btc->getinfo());

?>


Debug shows error occurs when jsonRPCClient tries to connect to the server. Either a "Connection timed out." or "Connection refused." error.

Bounty goes to the first person to give me a working solution to this problem.

Solutions I've Tried

Open all ports on netstat. Nope. All open. VPS hoster is not blocking any ports their side.

Is it listening? Yup, it is, so this shouldn't be a problem.

Code:
netstat -nlp | grep 8332
tcp6       0      0 :::8332                 :::*                    LISTEN      19482/bitcoind



try to connect this way :

$btc = new jsonRPCClient(http://username:password@host:8332);

instead of
$btc = new jsonRPCClient("http://username:password@host:8332/");

tell me if it changes something :)


Title: Re: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: icanscript on February 25, 2015, 01:27:48 AM
I notice its listening on IP6 only, Should be IP4 and IP6.

for the reason of testing... remove

Quote
rpcallowip=IP.OF.WEB.SERVER

IP of webserver will need to be loopback usually, so 127.0.0.1 in most cases. Not the public facing IP.



Title: Re: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: Vortex20000 on February 25, 2015, 01:28:44 AM
Also, for the reason of testing... remove

Quote
rpcallowip=IP.OF.WEB.SERVER

also IP of webserver will need to be loopback usually, so 127.0.0.1 in most cases. Not the public facing IP.
What do you mean?

Explain it to a dummy :)

--snip--

try to connect this way :

$btc = new jsonRPCClient(http://username:password@host:8332);

instead of
$btc = new jsonRPCClient("http://username:password@host:8332/");

tell me if it changes something :)

Will try.


Title: Re: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: icanscript on February 25, 2015, 01:29:59 AM
Also, for the reason of testing... remove

Quote
rpcallowip=IP.OF.WEB.SERVER

also IP of webserver will need to be loopback usually, so 127.0.0.1 in most cases. Not the public facing IP.
What do you mean?

Explain it to a dummy :)

--snip--

try to connect this way :

$btc = new jsonRPCClient(http://username:password@host:8332);

instead of
$btc = new jsonRPCClient("http://username:password@host:8332/");

tell me if it changes something :)

Will try.

Try,

Code:
server=1
daemon=1
listen=1
rpcuser=username
rpcpassword=password
rpcport=8332

If that works, Try

Code:
server=1
daemon=1
listen=1
rpcuser=username
rpcpassword=password
rpcallowip=127.0.0.1
rpcport=8332


Title: Re: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: Vortex20000 on February 25, 2015, 01:40:57 AM
Nope. Neither of you guys' solutions works. Thanks for your time, though.


Title: Re: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: Shadow_Runner on February 25, 2015, 01:56:13 AM
rpcallowip=*
works at all?


Title: Re: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues
Post by: Vortex20000 on February 25, 2015, 02:14:49 AM
rpcallowip=*
works at all?

In the later version of bitcoind I do believe this is something like:

Code:
::/0

No. It doesn't work.

Anyway, I've figured out a fix/workaround. Since I can connect locally, I am hosting a webserver on the VPS as an API to connect to bitcoind. From my site, I can POST/GET to the API and perform operations thus.