[zeromq-dev] restful access
james.gatannah at gmail.com
Wed Aug 6 14:18:20 CEST 2014
On Tue, 5 Aug 2014 18:58:29 +0800
"bino oetomo" <bino at indoakses-online.com> wrote:
> Dear All ..
> I need kind of http-to-0MQ bridge
> After some google search .. I still have no luck.
> here my conditions :
> 1. I have a Flask based web-app.
> 2. For some (not all) kind of POST method , I need to send the request
> data to a Job-queue
> My first try is : put zmq Push and Pull inside my Flask script ... just
> like http://pastebin.com/UrJC1jGc
> It works, as long as flask is run stand alone.
> I need it to be multi threaded ..
FWIW, my gut reaction anytime someone uses that sort of wording is
"then you probably shouldn't be using python." 0mq makes it less
horrible, but...you're fighting a fundamental part of the language
that probably won't ever go away.
> so :
> 1. Move the consumer part to external script, change the protocol to TCP
> 2. I run the Flask from twistd, just like :
> ~/Documents/rest$ twistd -n web --port 8050 --wsgi myrest.app
> Here the problem occurs,
> curl call to the service is good , but when I run the consumer script ..
> it don't receive any msg from the queue.
Are the requests from the consumer script getting to the request
handler? If it works over curl, then you probably have the 0mq side
wired up correctly. Along with the HTTP-to-0mq bridge. I'd be inclined
to suspect something else.
> Kindly please give me any suggestions.
> Is there any http-to-zmq bridge ?
I can't share any details, because it's proprietary closed source,
but I've written pretty much exactly this. Except that I used tornado
as the web server. I've never had any issues at all. Maybe there's
something about the differences in the way twistd and 0mq do
multi-threading? Or something about the way twistd interacts with
flask (I've never even read about that particular combination)?
Your paste binds to a TCP socket, then connects to an inproc. Is it
possible you have something like that going on? (Probably not, since
you said it works over curl).
I think the #1 frustration I have with my current app (besides the
fact that it's multi-threaded python that doesn't let 0mq handle all
the threaded parts) is that I haven't had time to write a simple GUI
client that I can hand to QA to prove that either a) the 0mq pieces
just work or b) there's something wrong with the network (for us, it's
almost always a firewall they misconfigured, though sometimes it's a
It might be worthwhile to set the HWM to 1, just to verify that no
receiver is managing to PULL. But now we're getting into general 0mq
debugging techniques, and the rest of the list is far more qualified
than I to help there.
More information about the zeromq-dev