1

I am using php to connect RPC server. In localhost, everything works fine. I moved my files to host to test and I realised that $geth->Method_Name() is not working.

If I print_r($geth), here is the result.

GethApi Object ( [_options:protected] => Array ( [version] => 2.0 [host] => 165.227.103.219 [port] => 8545 [assoc] => 1 ) [_address:protected] => http://165.227.103.219:8545 [_id:protected] => 0 )

But if I wanna get block number with $geth->eth_blockNumber() here is the result in localhost:

4495121

But in php server:

Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to connect to 165.227.103.219 port 8545: Connection refused' in /home/crypuekb/public_html/GethApi.php:86

  | Stack trace:   | #0 /home/crypuekb/public_html/GethApi.php(152): GethApi->;__call('eth_blockNumber', Array)   | #1 /home/crypuekb/public_html/geth.php(14): GethApi->eth_blockNumber()   | #2 /home/crypuekb/public_html/php/db.php(7): require_once('/home/crypuekb/...')   | #3 /home/crypuekb/public_html/register.php(4): include('/home/crypuekb/...')   | #4 {main}   | thrown in /home/crypuekb/public_html/GethApi.php on line 86

Here is the line 86:

throw new \RuntimeException(curl_error($curl), curl_errno($curl));

I am using this command to start geth server:

geth --rpcapi "web3,eth,personal" --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --light

As I said, everything works perfect on localhost.. Also my php server and ethereum server is based on different hosts. And I tried my php codes at three different hosts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.