AsyncTcpConnection连不上tcp的响应事件

kute1654

我是这个月下的Windows版本的workerman,为什么还是出现“AsyncTcpConnection连不上tcp的响应事件”的问题,我看之前的帖子不是说已经解决了么?
代码如下:

public static function start(){
               self::$slave_tcp_worker = new Worker("MyTextProtocol://0.0.0.0:2348");
        // 启动4个进程对外提供服务
        self::$slave_tcp_worker->count = 4;

        self::$slave_tcp_worker->onWorkerStart = function($worker)
        {
            echo "Worker starting...\n";
            tcp_client::connect_master("127.0.0.1", 2347);
        };
}
public static function connect_master($ip, $port){
        self::$master_tcp_connection = new AsyncTcpConnection('MyTextProtocol://'.$ip.':'.$port);
        self::$master_tcp_connection->onConnect = function($connection)
        {
            echo "connect success\n";
        };
        self::$master_tcp_connection->onMessage = function($connection, $http_buffer)
        {
        };
        self::$master_tcp_connection->onClose = function($connection)
        {
            echo "master connection closed\n";
            tcp_client::clear_timer(tcp_client::$client_master_send_timer);
            //60秒后重新连接
            var_dump($connection);
            $connection->reConnect(6);
        };
        self::$master_tcp_connection->onError = function($connection, $code, $msg)
        {
            echo "Error code:$code msg:$msg\n";
            tcp_client::clear_timer(tcp_client::$client_master_send_timer);
            //60秒后重新连接
            $connection->reConnect(6);
        };
        echo "connect";
        self::$master_tcp_connection->connect();
    }
2577 2 0
2个回答

mdx2007

你服务端监听的2348端口,然后telnet 2347端口?

  • 暂无评论
kute1654

请仔细看下代码,是监听2348端口的同时连接2347端口。这是一个双链接。

  • 暂无评论
年代过于久远,无法发表回答
×
🔝