Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session stop getting data when network error occurs. #37

Closed
RomanBurunkov opened this issue Apr 14, 2017 · 2 comments
Closed

session stop getting data when network error occurs. #37

RomanBurunkov opened this issue Apr 14, 2017 · 2 comments

Comments

@RomanBurunkov
Copy link

Hi,
I've created such function with closure

getPing = function(host, cbSuccess, cbError, reqTimeout){
  var timeout   = (reqTimeout || 2)*1000;
  var session   = netPing.createSession({
    packetSize : 64,
    retries    : 2,
    timeout    : timeout
  });
  session.on('error', function(error){
    logMsg(`ping on error ${host} error: ` + error.toString());
    session.close ();
  });
  return ()=>{
    session.pingHost(host, (error, target, sent, rcvd)=>{
      if(error) {
        logMsg(`ping ${target} error: ` + error.toString());
        cbError(error.toString());
      } else {
        var rtt = rcvd - sent;
        cbSuccess({status:'ok', result:'ok', data:rtt});
      }
      session.close();
    });
  }
}

It works, but if I got in log: ping 10.3.4.21 error: RequestTimedOutError: Request timed out,
it will stop calling callbacks until I restart whole project.

Any suggestion how to correct this issue?

Thanks, Roman.

@stephenwvickers
Copy link
Collaborator

Hi @RomanBurunkov,

It's hard to know without visiblity of cbSuccess and cbError and their surround code.

I'm guessing that calling the error callback on request timeout and not the success callback halts the flow of your program.

Steve

@RomanBurunkov
Copy link
Author

Dear @stephenwvickers , thanks for your reply.
You are right, I rewrote my app and at this moment I don't see any errors or stucks.
Sorry for that, but I really checked whole my program several times before adding this issue, and I didn't find a reason for such behaviour.

Thanks, Roman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants