[zeromq-dev] Reconnect doesn't work for Push-pull socket if push server goes down unsafely

Pieter Hintjens pieterh at gmail.com
Sat Sep 29 11:32:15 CEST 2012


Thanks, will you make an issue for this?
On Sep 28, 2012 2:58 PM, "Sunil khatri" <sunil.ncb at gmail.com> wrote:

> Scenario:
> Start a push server bind on tcp transport. Start a pull client which
> connects to above tcp endpoint. Wait for 5 seconds. Kill the server. Now if
> I restart the server again client is not re-connecting.
> When I check netstat -antp, connection remains in close_wait state.
>
> This case works fine with version-2.2.
> Test code:
>
> ====
> ///zmq_s.cpp
> #include <zmq.hpp>
>
> //using namespace zmq;
> zmq::context_t g_zmqcontext(1);
> int main()
> {
>         try{
>         zmq::socket_t s1(g_zmqcontext, ZMQ_PUSH);
>         s1.bind("tcp://*:5556");
>         int i=0;
>                 while(1){
>                         char str[100];
>                         sprintf(str, "Hi-%d", i++);
>                         zmq::message_t msg(strlen(str));
>                         memcpy(msg.data(), str, strlen(str)+1);
>                         puts("Sending message");
>                         s1.send(msg);
>                         puts("Send done");
>                 }
>         }catch(zmq::error_t &e){
>                 printf("Error :%d-%s\n", e.num(), e.what());
> fflush(stdout);
>         }
> }
> --------------------
>
> //zmq_c.cpp
> #include <zmq.hpp>
>
> zmq::context_t g_zmqContext(1);
> int main(){
>         try{
>                 zmq::socket_t s2(g_zmqContext, ZMQ_PULL);
>                 s2.connect("tcp://127.0.0.1:5556");
>                 while(1){
>                         zmq::message_t msg;
>                         puts("Waiting for message");
>                         s2.recv(&msg);
>                         printf("Msg received: %s\n", msg.data());
> fflush(stdout);
>                         usleep(1);
>                 }
>         }catch(zmq::error_t &e){
>                 printf("Err:%s-%d\n", e.num(), e.what()); fflush(stdout);
>         }
> }
>
> ==============
>
> Regards
> Sunil Kharti
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120929/a6e013e9/attachment.htm>


More information about the zeromq-dev mailing list