I am trying to run a special Python "Hello World" program that uses ZeroMQ. I believe I need only one server to do this. I really want to use ZeroMQ. I used this code:
#
# Hello World client in Python
# Connects REQ socket to tcp://localhost:5555
# Sends "Hello" to server, expects "World" back
#
import zmq
context = zmq.Context()
# Socket to talk to server
print("Connecting to hello world server…")
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
# Do 10 requests, waiting each time for a response
for request in range(10):
print("Sending request %s …" % request)
socket.send(b"Hello")
# Get the reply.
message = socket.recv()
print("Received reply %s [ %s ]" % (request, message))
Above was taken from http://ift.tt/18doCx4 I named it hello.py
I ran it. It prints a couple lines then pauses indefinitely after echoing "Sending request 0." Eventually a use ctrl-c to make it stop. Here is what I see:
[root@ip-xxx.xxx.xxx.xxx zeromq-4.0.5]# python hello.py
Connecting to hello world server
Sending request 0
^CTraceback (most recent call last):
File "hello.py", line 22, in <module>
message = socket.recv()
File "zmq/backend/cython/socket.pyx", line 631, in zmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:5772)
File "zmq/backend/cython/socket.pyx", line 665, in zmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:5572)
File "zmq/backend/cython/socket.pyx", line 139, in zmq.backend.cython.socket._recv_copy (zmq/backend/cython/socket.c:1725)
File "zmq/backend/cython/checkrc.pxd", line 11, in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/socket.c:6022)
KeyboardInterrupt
What is wrong with my Hello World program? I am using RHEL 7 on AWS. I have a security opening for the server to accept all inbound and outbound traffic to/from the IP address of the server itself. I'm not sure if there is a security issue or not. It seems like iptables isn't running. Is it?
[root@ip-xxx.xxx.xxx.xxx zeromq-4.0.5]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
FYI Someone asked about this 3.5 years ago. There didn't seem to be a solution. For the sake of Python and ZeroMQ, I think a solution could benefit the community.
Aucun commentaire:
Enregistrer un commentaire