0

Hi have some code dnode function with callback:

    const dnode = require('dnode');
    const request = require('request');
    const daemon = dnode.connect(45848); 

    function requestInfo() {
            daemon.on('remote', (rpc) => {
                rpc.status(callback);
            });
            var callback = (err, infos) => {
                ...........
                request.post({
                    .........
                });
            }
        }

when i request it once just when script executed all is ok. Info send and requesting, but when i use for example setTimeout(requestInfo, 10000); or interval the script is stuck and don't execute even 1 time.

I need to rpc.status(callback); every minute

Beliaf
  • 577
  • 2
  • 8
  • 25
  • When you pass in the function `requestInfo` to `setTimeout()`, is the variable `daemon` still referring to the object you want it to refer to when the function is ran? `daemon` might have not been declared in your `setTimeout`'s callback function (`requestInfo`) unless you you used `.bind()` on the callback being passed into `setTimeout` – Jun Park Nov 05 '17 at 09:51
  • Deamon is dnode connect . Add full script. May you add example. Node js isn't may strong side:) – Beliaf Nov 05 '17 at 10:16
  • Can you also show where you are calling `setTimeout`? – Jun Park Nov 05 '17 at 14:04

0 Answers0