I want to make a simple connection between a Python program and a Ruby program using ZeroMQ, I am trying to use a PAIR connection, but I have not been able.
This is my code in python (the server):
import zmq
import time
port = "5553"
context = zmq.Context()
socket = context.socket(zmq.PAIR)
socket.bind("tcp://*:%s" % port)
while True:
socket.send(b"Server message to client3")
print("Enviado mensaje")
time.sleep(1)
It does not display anything until I connect a client.
This is the code in Ruby (the client)
require 'ffi-rzmq'
context = ZMQ::Context.new
subscriber = context.socket ZMQ::PAIR
subscriber.connect "tcp://localhost:5553"
loop do
address = ''
subscriber.recv_string address
puts "[#{address}]"
end
The ruby script just freezes, it does not print anything, and the python script starts printing Enviando mensaje
B.T.W: I am using Python 3.6.9 and Ruby 2.6.5
What is the correct way to connect a zmq PAIR
between Ruby and Python?