Skip to content

onFail() handler isn't always called when the device is offline #39

@blindman2k

Description

@blindman2k

I am not sure if this happens in other circumstances as well but if you set the onFail() handler to the DataMessage object returned by send() and the device is not connected (specifically, when _isConnected() returns false) then the onFail() handler isn't called.

This doesn't fire the onFail() handler:

local dm = mm.send("ping", true);
dm.onFail(function(msg, error, retry) {
    server.error("PING failed")
});

But this does fire the onFail() handler:

mm.onFail(function(msg, error, retry) {
    server.error("PING failed")
});
mm.send("ping", true);

Note the device has to be detected as offline (_isConnected() must return false) not just be offline. If the device is offline but the agent doesn't know it then you get a onTimeout() event instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions