2
Just before few hour I have setup bitcoin daemon on my ubuntu server and tested it with API and it is responding very well. Now I have installed litecoin daemon on the same server and used copied the same php files with a little sytax changes like change in username and password and port number but it is not responding to any API calls.
Content of litecoin.conf are :
server=1
daemon=1
rpcuser=my_username
rpcpassword=mypassword
rpcport=9332
Content of litecoin.php
<?php
include_once('jsonRPCClient.php');
$variable = $_GET['variable'];
$litecoin = new jsonRPCClient('http://my_user:my_password@127.0.0.1:9332/');
if($variable=='getnewaddress')
{
echo $litecoin->getnewaddress();
}
else if($variable=='getinfo')
{
print_r($litecoin->getinfo());
}
else
{
echo "hello";
}
?>
Any help of what I am doing wrong here ?
I was trying to figure out why php file is not throwing any error if there is any then I discovered that error_reporting in php.ini file is turned off after turning it on I got following error while executing litecoin.php on the browser :
Warning: fopen(http://...@myserveraddress.com:9332/): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /var/www/jsonRPCClient.php on line 132
Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://myuser:mypassword@myserveraddress.com:9332/' in /var/www/jsonRPCClient.php:140 Stack trace: #0 /var/www/litecoin.php(12): jsonRPCClient->__call('getinfo', Array) #1 /var/www/litecoin.php(12): jsonRPCClient->getinfo() #2 {main} thrown in /var/www/jsonRPCClient.php on line 140
You are using HTTP, so you can use an IP packet sniffer to see what's going on. Is your connection accepted by the server? Does the server respond with any kind of HTTP response? – Greg Hewgill – 2014-01-12T22:15:44.517
@GregHewgill I have used the same file with bitcoin daemon with different parameters and its working fine. But litecoin is not working – Khan Shahrukh – 2014-01-12T22:23:08.627
Yes, you already said it wasn't working, but you haven't given any information that would allow anybody to guess a reason. I am suggesting a method for you to do some diagnostics to find out why it is not working. – Greg Hewgill – 2014-01-12T23:59:22.710
Try taking out the
server=1parameter from your litecoin.conf.If the
rpcuserandrpcpasswordvalues are literal in the above configuration (which I expect not) they should match with your$litecoinstring (which they don't).Run
ifconfig -a | grep 9332to see if there is a listening port for 127.0.0.1 (0.0.0.0 is not enough). – George Kimionis – 2014-01-13T00:09:29.017