zeromq / php-zmq

ZeroMQ for PHP
http://pecl.php.net/zmq
Other
551 stars 119 forks source link

Issue : after disconnect() return true but the system socket is still ESTABLISHED #146

Open thues opened 9 years ago

thues commented 9 years ago

version: zeromq: 4.0.5 php-zmq: 1.1.2

client [REQ] : written in php server[ROUTER]: written in C

when i called disconnect() in the client ,it returned true. but the system socket handle is still ESTABLISHED there after the command of 'netstat', only when i restart the Apache server the socket turned TIME_WAIT.

maxymajzr commented 9 years ago

Can you provide some code? If I'm not mistaken, disconnect() is asynchronous in ZMQ. However if you can provide some reproduction code, I would be more than happy to run it and to help out if possible.

thues commented 9 years ago

client.php run in Nginx


$queue = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, "MySock1");
$queue->connect("tcp://172.16.2.7:7777");
$queue->send("hello there, using socket 1");
$queue->disconnect("tcp://172.16.2.7:7777");

router.cpp run on centos


#include "zhelpers.hpp"
int main(int argc, char *argv[])
{
    zmq::context_t context(1);
    zmq::socket_t responder(context, ZMQ_ROUTER);
    responder.bind("tcp://*:7777");
        while(1) {
        std::string message = s_recv(responder);
        s_send(responder,"responder received");
    }       
}

if run command "netstat -anlp | grep 7777" the socket is still ESTABLISHED, and it can be closed when we stop 'php-fpm'. Actually what i want to do is destroy the socket and re-connect to the server.