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

Potential Incorrect Reuse of NDEATH Payload in Java Code #302

Open
joshwheeler-ggrx opened this issue Jul 9, 2023 · 0 comments
Open

Potential Incorrect Reuse of NDEATH Payload in Java Code #302

joshwheeler-ggrx opened this issue Jul 9, 2023 · 0 comments

Comments

@joshwheeler-ggrx
Copy link

In EdgeClient::connectToTargetServer, we have the following block of code that is making the connection to the server:

// Connect to the MQTT Server
options.setAutomaticReconnect(true);
options.setCleanSession(true);
options.setConnectionTimeout(30);
options.setKeepAliveInterval(30);
options.setUserName(username);
options.setPassword(password.toCharArray());
options.setWill(NAMESPACE + "/" + groupId + "/NDEATH/" + edgeNode, deathBytes, 0, false);
client = new MqttClient(serverUrl, clientId);
client.setTimeToWait(2000); 
client.setCallback(this);                   // short timeout on failure to connect

The deathBytes come from MetricHandler.getDeathPayloadBytes(). The issue is that by reusing the death payload, the nodes on the network cannot distinguish between an unexpected network disconnect, or a graceful shutdown.

The cleanest fix would most likely be to add a MetricHandler.getLWTPayloadBytes() (Last Will and Testament). The dirty hack would be to have everyone interested on the network check for a metric akin to GracefulShutdown, which I don't recommend.

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

1 participant