I have a ZeroMQ PUB/SUB
connection between a server and clients written in Python. The server sends a message and the client prints it out.
These programs work perfectly fine in the same computer ( either Ubuntu 16.04, or Windows 7; both work ).
They also work when the server is on the Windows 7 machine and the client is on the Ubuntu 16.04 machine.
However, if the server is on the Ubuntu 16.04 machine then the client on the Windows 7 machine cannot connect to it.
Also, there is not a problem of communication when I move the client and server programs between two separate Windows 7 machines.
Does anyone know what the problem might be?
Here is the client code:
#Based on code found on this Stack Overflow post:
#https://stackoverflow.com/questions/43817161/how-to-send-opencv-video-footage-over-zeromq-sockets
import cv2
import zmq
import base64
import numpy as np
context = zmq.Context()
footage_socket = context.socket(zmq.SUB)
address = 'tcp://192.168.128.229:5555'
footage_socket.connect(address)
footage_socket.setsockopt_string(zmq.SUBSCRIBE, unicode(''))
print "start"
print "connecting to ", address
while True:
try:
frame = footage_socket.recv_string()
img = base64.b64decode(frame)
npimg = np.fromstring(img, dtype=np.uint8)
source = cv2.imdecode(npimg, 1)
cv2.imshow("image", source)
cv2.waitKey(1)
except KeyboardInterrupt:
cv2.destroyAllWindows()
print "\n\nBye bye\n"
break
Here is the server code:
#Based on code found on this Stack Overflow post:
#https://stackoverflow.com/questions/43817161/how-to-send-opencv-video-footage-over-zeromq-sockets
import cv2
import zmq
import base64
context = zmq.Context()
footage_socket = context.socket(zmq.PUB)
footage_socket.bind('tcp://*:5555')
footage_socket.setsockopt(zmq.CONFLATE, 1)
camera = cv2.VideoCapture(0)
while True:
try:
(grabbed, frame) = camera.read()
frame = cv2.resize(frame, (640, 480))
encoded, buffer = cv2.imencode('.png', frame)
footage_socket.send_string(base64.b64encode(buffer))
except KeyboardInterrupt:
camera.release()
cv2.destroyAllWindows()
print "\n\nBye bye\n"
break