[zeromq-dev] Strange problem with lua-zmq on Windows

Robert G. Jakabosky bobby at sharedrealm.com
Thu Aug 11 05:03:40 CEST 2011


On Wednesday 10, Ross Andrews wrote:
> I'm not sure if this is a Windows problem, a Lua problem, a ZeroMQ problem,
> or a my-code problem, but after about three weeks I am finally able to
> reproduce it in a small example so here goes.
> 
> Here's the server:
> 
> require 'zmq'
> 
> ctx = zmq.init(1)
> socket = ctx:socket(zmq.REP)
> socket:bind 'tcp://*:4568'
> n = 0
> 
> while true do
>    socket:recv()
>    n = n + 1
>    print(n)
>    socket:send('pong')
> end
> 
> socket:close()
> 
> ----------
> 
> And here's the client:
> 
> require 'zmq'
> 
> ctx = zmq.init(1)
> k = 0
> 
> while k < 10 do
>    local n, sockets = 0, {}
> 
>    while n < 50 do
>       local socket = ctx:socket(zmq.REQ)
>       socket:connect('tcp://localhost:4568')
>       socket:send('ping')
>       table.insert(sockets, socket)
>       n = n + 1
>    end
> 
>    for _, socket in ipairs(sockets) do
>       print(socket:recv())
>       socket:close()
>    end
> 
>    k = k + 1
> end
> 
> ----------
> 
> The idea is that I have a client that accepts requests, spawns threads (or
> maybe uses a thread pool, either way I can't control it) to handle them.
> "Handling them" consists of creating a REQ socket, sending a request to
> another (single-threaded) thing to handle them and give a response back,
> and then returning the response. I have to make a new socket each time
> because I can't control which thread the requesting thing is on, and I
> can't share ZMQ sockets across threads.
> 
> The problem is that this case thrashes and then eventually kills lua-zmq.
> It should handle 500 messages here, actually it dies at an indeterminate
> point between about 100 and about 400.
> 
> Can anyone give me a clue what's going on?


Try the attached C version of those scripts to help narrow down where the 
problem is.  I have only tested the code on Linux, but it should be simple to 
compile it on Windows.

Using the C version on my Linux system with zmq 2.1.7, I see short pauses when 
running the client with these parameters:
./test_req_client 100 200

but it does finish all requests.  The pauses might be happening because of the 
high number of tcp connections being open/closed in a short period.

-- 
Robert G. Jakabosky
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_rep_server.c
Type: text/x-csrc
Size: 802 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110810/fdb9f7bf/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_req_client.c
Type: text/x-csrc
Size: 1733 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110810/fdb9f7bf/attachment-0001.c>


More information about the zeromq-dev mailing list