Bitcoin Forum
June 04, 2024, 03:09:41 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [0.1 BTC Bounty] Fix My JSONRPC Bitcoind-PHP Issues  (Read 1773 times)
Vortex20000 (OP)
Hero Member
*****
Offline Offline

Activity: 504
Merit: 500

sucker got hacked and screwed --Toad


View Profile WWW
February 25, 2015, 01:01:39 AM
 #1

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


yogg
Legendary
*
Offline Offline

Activity: 2464
Merit: 3158



View Profile WWW
February 25, 2015, 01:12:46 AM
 #2

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 Smiley
icanscript
Hero Member
*****
Offline Offline

Activity: 686
Merit: 502



View Profile
February 25, 2015, 01:27:48 AM
 #3

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.

Vortex20000 (OP)
Hero Member
*****
Offline Offline

Activity: 504
Merit: 500

sucker got hacked and screwed --Toad


View Profile WWW
February 25, 2015, 01:28:44 AM
 #4

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 Smiley

--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 Smiley

Will try.

icanscript
Hero Member
*****
Offline Offline

Activity: 686
Merit: 502



View Profile
February 25, 2015, 01:29:59 AM
 #5

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 Smiley

--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 Smiley

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
Vortex20000 (OP)
Hero Member
*****
Offline Offline

Activity: 504
Merit: 500

sucker got hacked and screwed --Toad


View Profile WWW
February 25, 2015, 01:40:57 AM
 #6

Nope. Neither of you guys' solutions works. Thanks for your time, though.

Shadow_Runner
Hero Member
*****
Offline Offline

Activity: 574
Merit: 500



View Profile
February 25, 2015, 01:56:13 AM
 #7

rpcallowip=*
works at all?
Vortex20000 (OP)
Hero Member
*****
Offline Offline

Activity: 504
Merit: 500

sucker got hacked and screwed --Toad


View Profile WWW
February 25, 2015, 02:14:49 AM
 #8

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!