iotagent-json icon indicating copy to clipboard operation
iotagent-json copied to clipboard

MongoError - Topology was destroyed

Open filgiuff opened this issue 5 years ago • 7 comments

Sometimes it happens that all calls to the agent don't work, The system returns this response

{
    "name": "MongoError",
    "message": "Topology was destroyed"
}

Restarting the agent the error disappears.

I'm using version 1.5.0

filgiuff avatar Oct 28 '19 14:10 filgiuff

Thanks for the report!

It could be some kind of problem in the IOTA connection to DB or in the DB itself. Maybe the logs of the IOTA could provide some useful information to help debugging this issue (the log can be long and verbose... I'd suggest to look near the timestamp when the problem starts to happen).

fgalan avatar Oct 28 '19 16:10 fgalan

Here it is a message from the log when this error happens:

iotstack_agent-json.1.qhlre44iss8j@vm-1    | time=2019-12-21T04:00:39.073Z | lvl=ERROR | corr=d6e924ac-9c55-447b-aff2-dc608caea292 | trans=d6e924ac-9c55-447b-aff2-dc608caea292 | op=IoTAgentNGSI.DomainControl | srv=n/a | subsrv=n/a | msg=DisconnectedError: Ran out of retries trying to reconnect to "mongodb:27017". Try setting `server.reconnectTries` and `server.reconnectInterval` to something higher. | comp=IoTAgent

filgiuff avatar Dec 23 '19 09:12 filgiuff

Which values do you have in your configuration for server.reconnectTries and server.reconnectInterval? Have you tried the advice of increasing them in order to see if the problem disappears?

fgalan avatar Jan 07 '20 09:01 fgalan

Which values do you have in your configuration for server.reconnectTries and server.reconnectInterval? Have you tried the advice of increasing them in order to see if the problem disappears?

Where are these configurations ? Which is the involved component ? (iotAgent or Mongodb ?)

filgiuff avatar Jan 07 '20 10:01 filgiuff

Where are these configurations ? Which is the involved component ? (iotAgent or Mongodb ?)

It corresponds to the mongodb.retries and mongodb.retryTime in config.js or IOTA_MONGO_RETRIES IOTA_MONGO_RETRY_TIME env vars (depending on the configuration style you are using).

The mongodb configuration is described in https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/installationguide.md:

he MongoBD driver will retry the connection at startup time retries times, waiting retryTime seconds between attempts, if those attributes are present (default values are 5 and 5 respectively)

fgalan avatar Jan 07 '20 11:01 fgalan

Following your suggestion, I put 2 environment variables with these value:

IOTA_MONGO_RETRIES=10 IOTA_MONGO_RETRY_TIME=10

on the agent configuration, but the problem happens again.

Do you know what can be the correct values to insert?

I'm still using the version 1.5.0

filgiuff avatar Feb 12 '20 15:02 filgiuff

I'm still using the version 1.5.0

This version is pretty old... Could you test with the newest one (1.12.0) please?

fgalan avatar Feb 20 '20 10:02 fgalan