2

My contract is deployed on ropsten infura test-network and that contract has events which gets fired when there is some transaction.

contract file

function functionName(address from, address destination, uint256 amount) stoppable public {
        myEvent(from, destination, amount);
}

I am trying to listen this event in my node js code in below manner

let web3 = new Web3()
web3.setProvider(new Web3.providers.WebsocketProvider('wss://ropsten.infura.io/ws'));

Contract.events.myEvent(function (err, res) {
      if (!err) {
        console.log('Event Log :', res);
      }
})

After restarting node server and doing instant transactions which calls method "functionName" from contract which emits event, node js is properly listening for the events and I am getting expected output.

But if I wait 5 min or more idle without making any transactions or any activity and if I make transaction after that interval the method from contract "functionName" is getting called but node js is not able to listen for that event.

Can any one please let me know if you face such issues ever.

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.