Question

I have built Catcoind (a fork of the Bitcoin / project) and I can access the commands in my terminal by doing this from root:

cd catcoin/src 
./catcoind -daemon

That will start Catcoind, open the port, and allow me to type commands like './catcoind getdifficulty', but I want to access them from a PHP JSON-RPC client running on another server. The code I currently have there is:

<?php

require_once 'jsonRPCClient.php'; 

$catcoin = new jsonRPCClient('http://RPCUSER:RPCPASS@IP:PORT'); 

print_r($catcoin->getinfo()); 
echo $catcoin->getdifficulty();

My config file for the Catcoind build on Ubuntu is:

server=1

rpcuser=USER

rpcpassword=PASS

rpcssl=0

rpcallowip=*

bind=IP:PORT

externalip=IP

proxy=IP:PORT

port=PORT

rpcconnect=IP

When I run the code, it says that it failed to open the stream / connection refused. The config for Catcoind is at location ~/.catcoin/catcoin.conf. Any ideas? I know this is confusing, but I have really everything done but allowing external IPs to access the API. Thanks! :D

Was it helpful?

Solution

You don't need all these things to be written in conf file just use following

server=1
daemon=1
rpcuser=<user_namer>
rpcpassword=<password>
rpctimeout=30

if connecting from remote host do add following line

rpcallowip=<remote_ip_address>

save and exit from conf file and restart daemon by first stopping it catecoind stop and then catcoind start

OTHER TIPS

Are external IP allowed? If not make sure that the IP is allowed so that it can call the api. The error failed to open the stream / connection refused usually means that the ip and everything is correct but the server rejected the connection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top