I am using Meteor & Web3 to talk to a Geth node, and would like to have an event fire in web3 when the Geth node goes down.

Web3 has the ability to add callbacks to web3.eth.isSyncing to detect changes, but web3.eth.isConnected does not.

How can I detect changes in web3.eth.isConnected without having to use continuous polling?

2 Answers 2


You can try web3.net.listening

// or async
web3.net.getListening(callback(error, result){ ... })

This property is read only and says whether the node is actively listening for network connections or not.


Boolean - true if the client is actively listening for network connections, otherwise false.

  • 1
    Thanks for the input. I tried adding web3.net.getListening(callback(error, result){ console.log(error,result}) to my meteor app. It fires on initialisation, but not when I stop the Geth node. My console is flooded with net::ERR_CONNECTION_REFUSED messages though.
    – billett
    Commented Apr 8, 2016 at 13:48
  • @glider so i assume its polling. a workaround is to fire web3.reset() when we have a ERR_CONNECTION_REFUSED
    – niksmac
    Commented Apr 8, 2016 at 14:00
  • Yeah, web3/syncing.js polls for changes. How would I detect an ERR_CONNECTION_REFUSED event within Meteor?
    – billett
    Commented Apr 8, 2016 at 14:18
  • @glider did you managed to get it work?
    – niksmac
    Commented Apr 10, 2016 at 1:34
  • Not yet, thanks for your input though. Haven't found a way of detecting net::ERR_CONNECTION_REFUSED events yet, any thoughts?
    – billett
    Commented Apr 10, 2016 at 11:45

For full disclosure, and whoever may stumble upon this question in the future, the following code was what I was looking for...

function status() {
    try {
    catch (e) {
//Call the status function every second
Meteor.setInterval(status, 1000);
  • Yep - looking at the network traffic between the client & server side, Meteor is constantly polling the server side, albeit with really small requests. So perhaps this is the proper way to do it.
    – billett
    Commented Apr 12, 2016 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.