monero-integrations / monerophp

Monero PHP library + JsonRPC Client
MIT License
119 stars 76 forks source link

Fatal error: Uncaught RuntimeException: Unable to connect to https://127.0.0.1:18081/ #134

Closed zac667 closed 1 year ago

zac667 commented 1 year ago

Hello, i meet an error on example.php, i started monerod on port 18089 ( he is 2 month behind), my monerod is running on a separate hard drive 1To. i started wallet rpc on port 20081 i try to run them both are on main net i am in localhost under xampp my monerod is Monero 'Fluorine Fermi' (v0.18.1.2-release) if someone can help a new monero devlopper to understand it ;)

Here is error :

Fatal error: Uncaught RuntimeException: Request have return error: Method not found; Request: {"jsonrpc":"2.0","method":"get_connections","params":null}; in C:\xampp\htdocs\monerophp-master\src\jsonRPCClient.php:151 Stack trace: #0 C:\xampp\htdocs\monerophp-master\src\jsonRPCClient.php(96): MoneroIntegrations\MoneroPhp\jsonRPCClient->validate(true, 'Request have re...') #1 C:\xampp\htdocs\monerophp-master\src\daemonRPC.php(112): MoneroIntegrations\MoneroPhp\jsonRPCClient->_run('get_connections', NULL, 'json_rpc') #2 C:\xampp\htdocs\monerophp-master\src\daemonRPC.php(374): MoneroIntegrations\MoneroPhp\daemonRPC->_run('get_connections') #3 C:\xampp\htdocs\monerophp-master\start.php(25): MoneroIntegrations\MoneroPhp\daemonRPC->get_connections() #4 {main} thrown in C:\xampp\htdocs\monerophp-master\src\jsonRPCClient.php on line 151

zac667 commented 1 year ago

When i setup $daemonRPC = new daemonRPC('127.0.0.1', 18081, false); a new error appear

Fatal error: Uncaught RuntimeException: Unable to connect to http://127.0.0.1:18081/ Error: Operation timed out after 8011 milliseconds with 0 bytes received in C:\xampp\htdocs\monerophp-master\src\jsonRPCClient.php:140 Stack trace: #0 C:\xampp\htdocs\monerophp-master\src\jsonRPCClient.php(80): MoneroIntegrations\MoneroPhp\jsonRPCClient->getResponse('{"jsonrpc":"2.0...', 'json_rpc') #1 C:\xampp\htdocs\monerophp-master\src\daemonRPC.php(112): MoneroIntegrations\MoneroPhp\jsonRPCClient->_run('get_info', NULL, 'json_rpc') #2 C:\xampp\htdocs\monerophp-master\src\daemonRPC.php(403): MoneroIntegrations\MoneroPhp\daemonRPC->_run('get_info') #3 C:\xampp\htdocs\monerophp-master\start.php(26): MoneroIntegrations\MoneroPhp\daemonRPC->get_info() #4 {main} thrown in C:\xampp\htdocs\monerophp-master\src\jsonRPCClient.php on line 140

zac667 commented 1 year ago

I found a solution by adding false for dont take care about SSL certificate

$walletRPC = new walletRPC('127.0.0.1', 18083, false); AND $daemonRPC = new daemonRPC('127.0.0.1', 18081, false);

After that i get error cause timeout in millisecond, so i upgrading connection timeout into jsonrpcclient.php (you can upgrade it to 1000 or 5000 (like you want)

CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120

After that an other bug, sometime wallet is "bugging" so you need to add this line $walletRPC->close_wallet(); beetween $walletRPC = new walletRPC('127.0.0.1', 18083, false); AND $walletRPC->open_wallet('monero_wallet2', ''); Sometimes you need to refresh, comment, refresh, uncomment but when it works, it works good.

here is my command for launch monerod (from hard drive) ./monerod --rpc-restricted-bind-ip 0.0.0.0 --rpc-restricted-bind-port 18089 --no-igd --no-zmq --confirm-external-bind --public-node --data-dir D:\

Here is my command for launch wallet (from hard drive) .\monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir D:\wallet

Hope it help someone like it help me <3