Mirobit / bitcoin-node-manager

:bar_chart: Lightweight dashboard and control system for bitcoin nodes
MIT License
122 stars 62 forks source link

Error loading the dashboard #32

Closed pouyiouk closed 3 years ago

pouyiouk commented 3 years ago

After the initial run and after some time that the peer list changes, the dashboard is not accessible. Error recieving is:

Fatal error: Uncaught Error: Call to undefined function App\curl_init() in /home/testbed/Downloads/bmn/src/Utility.php:662 Stack trace: #0 /home/testbed/Downloads/bmn/src/Utility.php(540): App\getIpData() #1 /home/testbed/Downloads/bmn/src/Utility.php(461): App\createPeersGeo() #2 /home/testbed/Downloads/bmn/src/Content.php(6): App\getPeerData() #3 /home/testbed/Downloads/bmn/index.php(78): App\createMainContent() #4 {main} thrown in /home/testbed/Downloads/bmn/src/Utility.php on line 662

After taking a closer look at the code, I pressume it has to do with the ip geolocation data. Is there any way to disable the geolocation service and only recieve the IP addresses of peers? I don't mind removing the chart and the map on the main screen just to see if it will work that way. Any other suggestions would be appreciated.

Mirobit commented 3 years ago

Thanks for reporting this error. You can turn the geo call off on the settings page of BNM. Do you have the curl php extension installed? If yes, check this.

pouyiouk commented 3 years ago

Yes, curl is installed. After restarting the node, the dashboard works again, but after a few minutes it does the same thing over again. After digging a little more, it is somewhat an error between the geolocation service and the node software reaching its maximum allowance of RPC calls, so it cannot actually retrieve any information regarding connected peers. I will try increasing the maximum stack of RPC calls allowed by a service connecting to bitcoind and report back on the findings, if the issue persists.

pouyiouk commented 3 years ago

@Mirobit As suspected. The rpc calls are too heavy for bitcoind to handle them. After increasing the stack of maximum rpcthreads and callbacks the issue stopped - might happen rarely if the bitcoind client is very busy. If I run the node with the default settings and if the number of peers is higher than 5+ all the information requested by the node software result in the following error:

Warning: fopen(http://...@127.0.0.1:8332/): failed to open stream: HTTP request failed! in /home/testbed/Downloads/bmn/src/jsonRPCClient.php on line 136

Fatal error: Uncaught Exception: Unable to connect in /home/testbed/Downloads/bmn/src/jsonRPCClient.php:144 Stack trace: #0 /home/testbed/Downloads/bmn/src/Utility.php(458): App\jsonRPCClient->__call() #1 /home/testbed/Downloads/bmn/src/Content.php(30): App\getPeerData() #2 /home/testbed/Downloads/bmn/index.php(154): App\createPeerContent() #3 {main} thrown in /home/testbed/Downloads/bmn/src/jsonRPCClient.php on line 144

Mirobit commented 3 years ago

I am surprised that bitcoind can't handle the gerpeerinfo call. I only experienced this once with a very full mempool. What are the specs of your machine? Does it work if you do the call via the terminal: bitcoin-cli gerpeerinfo?

pouyiouk commented 3 years ago

Yes it does work. System wise I am running on a server envi. with i9-1080xe and 32gigs ram. So my theory from what I've noticed is: once the client is completely synced and no writing of any blocks is happening rpc commands go through like a charm. Even with the default rpcthreads number bitcoind doesn't hung up or close the connection.

I have retried to replicate the issue and I can confirm, if the node software is synchronising and the default number of rpcthreads is set I can get all of the above error messages including geolocation errors. If syncing is done, no issues and loading times are very fast. So the issue is actually with the bitcoind not being able to handle everything at once (synchronising, writing blocks to disk, reading blocks + getting rpc calls - either peer information, block statistics etc.)

I think it would be good to add an initial message/loading page showing the percentage of synchronisation of the nodewith the chain and after 100% sync to allow the dashboard to load maybe?

mankwes commented 3 years ago

Hi there i 'm having the same problem as @pouyiouk , can't connect to bitcoin with bitcoin-node-manager. When i did it with curl it was working.

My server is Intel(R) Atom(TM) CPU C2750 @ 2.40GHz + 16giga Ram on debian 10

Mirobit commented 3 years ago

@mankwes is your client fully synced? What version of bitcoin core are you running?

I think it would be good to add an initial message/loading page showing the percentage of synchronisation of the nodewith the chain and after 100% sync to allow the dashboard to load maybe?

I am not sure that is possible since probably all RPC calls fail.

mankwes commented 3 years ago

@Mirobit it is full sync and my version is 0.20.1

Mirobit commented 3 years ago

@mankwes @pouyiouk I refactored the RPC call (now using curl) and the error handling. Please try with the latest version (1575de42475fb758f431d934b1a45916008797c3) Other than that I am out of ideas.

mankwes commented 3 years ago

@Mirobit sorry for the delay it is working flawlessly

pouyiouk commented 3 years ago

I can confirm the same. I am closing the issue. Thank you very much for the effort.

Mirobit commented 3 years ago

Thank you two for bringing this to my attention. By replacing fopen BNM should be more reliable for everyone.