-
Notifications
You must be signed in to change notification settings - Fork 83
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
issue with server-client example #27
Comments
@epifanio I just ran the code you posted above and it works both on a Raspberry Pi and on Ubuntu 17.04. I am using the same versions of python and zmq as you on the raspberry pi. On Ubuntu I am using python 3.5.3. |
Hi @MrYsLab, thanks for confirming it does for you. Now I wander way is not working on my other laptop (same osx version) , I'll check if has something to do with the fireall .. any clue on how to debug "a denied connection" ? |
I just tried on a different machine here in the office and it works fine! I'll investigate why on my laptop is not working .. Thanks for confirming that it should work. I |
Oh! seems I found the problem. This I guess has to do with my lack of knowledge about zmq and tcp /socket connection I guess... To reproduce the problem:
If I stop/restart the server (and leave the client running) I can see it still work fine. I think the code needs to be changed to handle "N" client to connect/disconnect .. I'll try to go through the documents to find a solution. Thanks for any pointer, a help will be great! |
I don't have much experience with pairs. I use pub/sub with a forwarder . The Python Banyan library makes extensive use of this pattern. |
Thanks for your help @MrYsLab.
import zmq
import random
import sys
import time
port = "5556"
if len(sys.argv) > 1:
port = sys.argv[1]
int(port)
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://0.0.0.0:%s" % port)
messaggio='ls -la'
socket.send_string(messaggio)
msg = socket.recv()
print(msg)
import os
import sys
import subprocess
import zmq
import random
import time
port = "5556"
if len(sys.argv) > 1:
port = sys.argv[1]
int(port)
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:%s" % port)
while True:
msg = socket.recv()
print('client meesage: ', msg)
gmsg=msg.split()
try:
proc = subprocess.Popen(gmsg, stdout=subprocess.PIPE)
output = proc.stdout.read()
socket.send_string(output)
except:
pass
time.sleep(0.5) Now it works as expected. |
@ashishrv thanks for this documentation.
I was trying to run the client-server example, but after I run the two scripts
pairserver.py
andpairclient.py
I can't see the messages printed in the shell. Nothing is printed. The scripts are:pairserver.py
pairclient.py
My
python
andpyzmq
versions are:The text was updated successfully, but these errors were encountered: