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

Addressing Potential Memory Leak Issue in ZMQ Connection Handling #239

Open
2 tasks done
ryan961 opened this issue Jul 1, 2024 · 1 comment
Open
2 tasks done

Comments

@ryan961
Copy link

ryan961 commented Jul 1, 2024

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

What happened?

While packaging ZMQ connections in the project to ensure high availability, the code uses dialEventSockLoop for constant proactive reconnection to ZMQ, which usually doesn't cause any issues.
However, if ZMQ disconnects during operation, and then we try to close the process, the goroutine becomes stuck here,

if err := b.dialEventSock(); err != nil {
log.WithError(err).Error("backend/concentratord: event socket dial error")
time.Sleep(time.Second)
continue
}

continuously trying to reconnect, hence preventing the process from exiting. It may be necessary to introduce an exit channel here to monitor the exit signals from the main program, thereby facilitating a smooth exit of the goroutine.
Moreover, it seems that the zmq package has some configurations like zmq4.WithAutomaticReconnect and zmq4.WithDialerMaxRetries... Would it be unnecessary, then, to attempt reconnections manually here?

@brocaar
Copy link
Collaborator

brocaar commented Aug 12, 2024

Instead of fixing this, maybe it is better to remove ZMQ support altogether. The MQTT Forwarder has been out already quite some time and has been recommended since then over installing the GW Bridge on gateways.

Recommendations:

  • On the gateway: MQTT Forwarder (accepting ZMQ + UDP)
  • On the server: GW Bridge (accepting UDP + Basics Station)

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