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

Analize: mosquitto restart loses mqtt agent topic subscriptions ? #524

Open
AlvaroVega opened this issue Jan 11, 2021 · 4 comments
Open

Comments

@AlvaroVega
Copy link
Member

A keepalive and a restart agent procedure would be a solution?

@AlvaroVega AlvaroVega changed the title mosquitto restart loses mqtt agent topic subscriptions Analize: mosquitto restart loses mqtt agent topic subscriptions ? Jan 11, 2021
@AlvaroVega
Copy link
Member Author

AlvaroVega commented Jan 11, 2021

UL done by https://github.com/telefonicaid/iotagent-ul/blob/329cfebbe7dd6359ef13ca30075349603dfaba9a/lib/bindings/MQTTBinding.js#L134
JSON done by

function recreateSubscriptions(callback) {
config.getLogger().debug(context, 'Recreating subscriptions for all devices');
function subscribeToTopics(topics, callback) {
config.getLogger().debug(context, 'Subscribing to topics: %j', topics);
mqttClient.subscribe(topics, null, function (error) {
if (error) {
iotAgentLib.alarms.raise(constants.MQTTB_ALARM, error);
config.getLogger().error(context, 'GLOBAL-001: Error subscribing to topics: %s', error);
callback(error);
} else {
iotAgentLib.alarms.release(constants.MQTTB_ALARM);
config.getLogger().debug(context, 'Successfully subscribed to the following topics:\n%j\n', topics);
if (callback) {
callback(null);
}
}
});
}

@AlvaroVega
Copy link
Member Author

related #525

@chandradeep11
Copy link
Contributor

@AlvaroVega
I'm investigating this issue.

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Feb 23, 2022

In this case

ota-json time=2022-02-21T12:32:54.702Z | lvl=ERROR | corr=4b9c69b5-86eb-466d-956b-2cf1c776c170 | trans=4b9c69b5-86eb-466d-956b-2cf1c776c170 | op=IOTAJSON.MQTT.Binding | from=n/a | srv=XXXX | subsrv=/YYYY | msg=GLOBAL-001: Error subscribing to topics: Error: Connection closed
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at /opt/iotagent-json/node_modules/mqtt/lib/client.js:105:29
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at Array.forEach ()
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at flushVolatile (/opt/iotagent-json/node_modules/mqtt/lib/client.js:103:24)
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at Socket. (/opt/iotagent-json/node_modules/mqtt/lib/client.js:304:5)
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at Socket.emit (events.js:314:20)
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at Socket.EventEmitter.emit (domain.js:506:15)
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at TCP. (net.js:675:12)
pro-core-smc-iota-json-6c7f4c7764-2cvrm smc-iota-json-container at TCP.callbackTrampoline (internal/async_hooks.js:126:14) | comp=IoTAgent

it seems that iotagent tries to reconnect but mosquitto refuse it.
Maybe related with the usage of random mqtt client_id by iota, non a fixed one provided with IOTA_MQTT_CLIENT_ID

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