I am using this curl function to connect to my digitalocean ip from my website, but am getting
"Error:Failed to connect to myip port 8332: Connection refused"
This is the call function am using
<?php
function bitcoin($method="getblockchaininfo"){
$ch = curl_init();
$rpcuser='rpcusername';
$rpcpassword='rpcpassword';
$host='nodeIP'; //IP address of your node or localhost, if running locally
$port='port';
curl_setopt($ch, CURLOPT_URL, "http://$rpcuser:$rpcpassword@$host:$port/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"jsonrpc\":\"1.0\",\"id\":\"curltext\",\"method\":\"$method\",\"params\":[]}");
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
return($result);
}
?>
But if i visit my digital ocean ip directly and call a specific bitcoind jsonrpc method, everything works fine.