So I have implemented a Blockchain websocket to my NodeJS, but it misses a transaction if I'm monitoring a address. What is the problem?
Function to start monitor:
function monitorAddress(address){
logger.trace("Starting to monitor address: " + address);
ws.send('{"op":"addr_sub", "addr":"' + address + '"}', function (error){
if(!error){
logger.info('Monitoring has been started for address: ' + address);
}
});
}
Pinging every 25 Seconds
setInterval(function () {
ws.send('{"op":"ping"}', function (error) {
if (!error) {
logger.info("Successfully pinged after 25 seconds.");
}
});
}, 25 * 1000);
Answer from Blockchain
ws.on('message', function incoming(data, flags){
var obj = JSON.parse(data);
console.log(data);
if(obj.op == 'utx'){
//transaction
}
)};
via Jordn
No comments:
Post a Comment