I am trying to subscribe to the ZeroMQ from my Quake Live server. I registered the server on QLStats (green status here: https://qlstats.net/panel2/servers.html), confirming that the PUB socket is functioning correctly. Below I pasted log entries where I can see the QLStats server authenticating correctly. However, my Rails worker using ffi-rzmq fails to receive any messages (I am running this locally on a brand new project).
Here is the Rails worker code:
require 'ffi-rzmq'require 'json'class ZmqSubscriberJob include Sidekiq::Job def perform context = ZMQ::Context.new subscriber = context.socket(ZMQ::SUB) username = ENV['ZMQ_USERNAME']&.b password = ENV['ZMQ_PASSWORD']&.b subscriber.setsockopt(ZMQ::PLAIN_USERNAME, username) subscriber.setsockopt(ZMQ::PLAIN_PASSWORD, password) zmq_url = "tcp://#{ENV['ZMQ_HOST']}:#{ENV['ZMQ_PORT']}" subscriber.connect(zmq_url) subscriber.setsockopt(ZMQ::SUBSCRIBE, '') Rails.logger.info "Connected to ZeroMQ PUB socket at: #{zmq_url}, listening for all events." loop do message = '' subscriber.recv_string(message) Rails.logger.info "Received message: #{message}" rescue => e Rails.logger.error "Error: #{e.message}" end ensure subscriber&.close context&.terminate endend
What I Have Verified:
- The Quake Live server logs confirm the PUB socket is running:
zmq PUB socket: tcp://0.0.0.0:27960
- I can also see that the QLStats server is logging in correctly:
I: 25-01-02 10:39:09 zauth: ZAP request mechanism=PLAIN ipaddress=23.88.103.193I: 25-01-02 10:39:09 zauth: - allowed (PLAIN) username=XXX password=XXXI: 25-01-02 10:39:09 zauth: - ZAP reply status_code=200 status_text=OK
- ZMQ_USERNAME and ZMQ_PASSWORD match the credentials configured in the server and shown in the logs.
- No error is logged by the Rails worker, but it does not receive any messages.
Environment Details
- Rails 7.2.2.1
- ffi-rzmq gem version 2.0.7
I looked at this to get a grasp about how it works: https://github.com/MinoMino/minqlx/blob/master/python/minqlx/_zmq.py
I tried to create a Python version just in case, but that didn't work either. I also created one in plain rails (no workers), no luck.
I believe it's something really simple that I am missing.
Could it be a problem with the version of ffi-rzmq
?Any pointers on how to solve this?