[zeromq-dev] PUSH/PULL connection reset issue

James Chapman james at linux-101.org
Thu Aug 13 14:56:11 CEST 2015


Please ignore my original message.

Linger!

*facepalm*





On 13 August 2015 at 13:28, James Chapman <james at linux-101.org> wrote:

> Resending, this time from the subscribed email address. Apologies if you
> receive this twice.
>
>
> Hi ZeroMQ community.
>
> I'm using ZeroMQ 4.1.2 in C++ and I've created a push pull pair of apps to
> demonstrate the issue I'm seeing.
>
> When the Push app sends messages with the Pull app, the push sends but the
> pull doesn't receive.
> In the process of trying to establish what was blocking the receive, I
> noticed that the push machine sends a SYN packet, the pull machine replies
> with a SYN ACK, and instead of the push machine sending a SYN ACK ACK, it
> sends a RST.
>
> The issue does not occur when running both apps on the same host.
>
> Push machine is Windows 2008 VM on Citrix Xen Server, Pull machine is
> Windows 10, although I don't believe the platform to be the issue.
>
> Is this a bug or have I done something very wrong?
>
> push/pull code below.
>
>
> Thanks
> James
>
>
>
>
>
>
> ------------------------------------------------
> // PUSH
> #include <iostream>
> #include <string>
> #include <thread>
> #include <chrono>
>
> #include "zmq.hpp"
>
>
> int main()
> {
>     for (int i = 0; i < 100; ++i)
>     {
>         ::zmq::context_t context(1);
>         auto pZmqSocket(new ::zmq::socket_t(context, ZMQ_PUSH));
>
>         std::string addressString = "tcp://192.168.0.5:9991";
>         pZmqSocket->connect(addressString.c_str());
>
>         int linger = 0;
>
>         pZmqSocket->setsockopt(ZMQ_LINGER, &linger, sizeof(linger));
>
>         std::string buffer = "Hello world!";
>
>         auto pZmqMsgOut(new ::zmq::message_t(buffer.length()));
>         memcpy(pZmqMsgOut->data(), buffer.c_str(), buffer.length());
>         pZmqSocket->send(*pZmqMsgOut);
>
>         std::cout << "Message sent" << std::endl;
>
>         pZmqSocket->disconnect(addressString.c_str());
>         pZmqSocket->close();
>
>         delete pZmqSocket;
>
>         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
>     }
>
>     return 0;
> }
>
>
> ------------------------------------------------
> // PULL
> #include <iostream>
>
> #include "zmq.hpp"
>
> int main()
> {
>     ::zmq::context_t zmqContext(1);
>     auto pPullSocket(new ::zmq::socket_t(zmqContext, ZMQ_PULL));
>
>     ::std::string pullSocketString = "tcp://0.0.0.0:9991";
>     pPullSocket->bind(pullSocketString.c_str());
>
>     ::zmq::pollitem_t items[] = {
>         { *pPullSocket, 0, ZMQ_POLLIN, 0 }
>     };
>
>     while (1)
>     {
>         auto pZmqMsgIn(new ::zmq::message_t());
>
>         zmq::poll(items, 1, -1);
>
>         if (items[0].revents & ZMQ_POLLIN)
>         {
>             std::cout << "rEvent" << std::endl;
>             auto bReceived = false;
>             if (pPullSocket->recv(pZmqMsgIn))
>             {
>                 bReceived = true;
>             }
>
>             if (bReceived)
>             {
>                 std::string buffer((char *)pZmqMsgIn->data());
>                 std::cout << "Received: " << buffer << std::endl;
>             }
>
>             delete pZmqMsgIn;
>         }
>     }
>
>     return 0;
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150813/f478d0ab/attachment.htm>


More information about the zeromq-dev mailing list