Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: sirtorvald on April 16, 2018, 03:53:34 PM



Title: Bitcoin connection with easybitcoin.php
Post by: sirtorvald on April 16, 2018, 03:53:34 PM
Hi. I was testing how betcoin daemon worked with easybitcoin.php, and there was a problem which drove me crazy. So, I tried to make a test, iis absolutly easy and there's no mistake
Code:
<?php

require_once 'easybitcoin.php';

$bitcoin = new Bitcoin("melog""mepass");

$ginf $bitcoin->getinfo();

print_r($ginf);

?>
And in the guide there was shown an information about the wallet. So, i looked through my bitcoin.conf file, and it was correct, port 8332 was open and could you just advise please, what to do to make it work?? PLEASE!!!
Bitcoin.conf: "
rpcpassword=mepass
rpcuser=melog
daemon=1
server=1
"


Title: Re: Bitcoin connection with easybitcoin.php
Post by: Sellingaccs on April 16, 2018, 04:07:51 PM
Not really familiar with php, but i suspect that the problem is indeed with ports or RPC details.
Try going to Canyouseeme.org (http://canyouseeme.org/) then enter your port and see if it can connect to it.

If yes, then i'd suggest replacing then i'd try this code instead:

Code:
<?php

require_once 'easybitcoin.php';

$bitcoin = new Bitcoin('melog','mepass','localhost','8332');

$ginf $bitcoin->getinfo();

print_r($ginf);

?>


And if that does not work either then i'd try adding the "rpcport=port" value into your config file.
Does it give out any errors?


Title: Re: Bitcoin connection with easybitcoin.php
Post by: bob123 on April 17, 2018, 08:50:34 AM
What problem exactly drives you crazy?

Did you 'open' the port? Note: When configuring the firewall on your router you need to configure port forwarding.
'Opening' ports mostly allows incoming connections to your router. This is not the same as forwarding (Forwarding = destination ports from packet header are being forwarded to the destination machine).

I think the majority of router does not distinguish between opening and forwarding. But there still quite a few which do.


Title: Re: Bitcoin connection with easybitcoin.php
Post by: mocacinno on April 17, 2018, 08:54:30 AM
Sellingaccs is correct... Here's the code from mocacinno.com:

Code:
<?php
require_once('easybitcoin.php');
$bitcoin = new Bitcoin('[your rcp username here]','[your rcp password here]','[bitcoind\'s ip address here]','8332');
?>


bob123 is also correct, your server can't have a firewall that blocks port 8332, the port has to be correct,.... This is testable by opening a console and entering:
Code:
lsof -i :8332

you can also try to open a telnet session from the host running the script to the host running the daemon (preferably the same host, since IIRC, json-rpc queries are sent in plain text)
Code:
telnet localhost 8332

oh, by the way, getinfo is depreciated.... i haven't updated my node yet, so i don't know if it's even still available...

Code:
{
  "deprecation-warning": "WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16",
  "version": 150100,
  "protocolversion": 70015,
  "walletversion": 60000,
  "balance": 0.00000000,
  "blocks": 518594,
  "timeoffset": 0,
  "connections": 30,
  "proxy": "",
  "difficulty": 3839316899029.672,
  "testnet": false,
  "keypoololdest": 1479499499,
  "keypoolsize": 1000,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}