[zeromq-dev] nginx, uwsgi and pyzmq

Pasithee Jupiter pasithee at gmail.com
Mon Dec 23 17:21:09 CET 2013


Hi All

I'm trying to create a zmq.PUSH socket from a uwsgi web application  and
get the following error when running a uwsgi web application under:

   - uWSGI 1.0.3-debian
   - nginx version: nginx/1.4.4
   - pyzmq==14.0.1
   - bottle==0.11.6

...
  File "/opt/www/vassals/../palm/webapp/map.py", line 226, in <module>
    broker = context.socket(zmq.PUSH)
  File
"/opt/virtualenv/palm/local/lib/python2.7/site-packages/zmq/sugar/context.py",
line 85, in socket
    s = self._socket_class(self, socket_type)
  File "socket.pyx", line 216, in
zmq.backend.cython.socket.Socket.__cinit__
(zmq/backend/cython/socket.c:2204)
zmq.error.ZMQError: Bad address


Does anyone has a idea?

Thanks in advance

P.S.: See below an excerpt of my approach


My application looks like the following:

*Web App (run under uwsgi and nginx):*

import bottle
import zmq.green as zmq

app = bottle.Bottle()

context = zmq.Context()
broker = context.socket(zmq.PUSH)
broker.connect('tcp://127.0.0.1:5000')

@app.get('/analyze')
@bottle.view('map/analysis')
def analyze():
    task_kwargs = {
        'algorithm' : session["map.selection"].algorithm
    }
    broker.send_json(task_kwargs)
    return dict()


*My broker as follow (start it manually in the console):*

import os, json
import zmq.green as zmq

context = zmq.Context()

pull_socket = context.socket(zmq.PULL)
pull_socket.bind('tcp://127.0.0.1:5000')

push_socket = context.socket(zmq.PUSH)
push_socket.bind('tcp://127.0.0.1:5001")

zmq.device(zmq.FORWARDER, pull_socket, push_socket)

pull_socket.close()
push_socket.close()

context.term()


*And a worker like this (start it manually in the console):*

import gevent
import zmq.green as zmq

context = zmq.Context()
broker = context.socket(zmq.PULL)
broker.connect('tcp://127.0.0.1:5001')

while True:
    try:
        task = broker.recv_json()
        gevent.sleep(2)
        print str(task)
    except Exception, e:
        print str(e)


broker.close()
context.term()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131223/b35782f4/attachment.htm>


More information about the zeromq-dev mailing list