simps / mqtt

🕹 MQTT Protocol Analysis and Coroutine Client for PHP. Support for 3.1, 3.1.1 and 5.0 versions of the MQTT protocol.

Home Page:https://mqtt.simps.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] composer 1.1.2版本 发生了重连之后就接收不到监听

wuxian12 opened this issue · comments

执行examples文件下ssl_ca.php

Command: php ssl_ca.php

在源码下面两处打印了下

public function recv()
    {
        $response = $this->getResponse();
        if ($response === '' || !$this->client->isConnected()) {var_dump($response,'*********');
            $this->close();
            $this->reConnect($this->config['reconnect_delay']);
            $this->connect($this->connectData['clean_session'] ?? true, $this->connectData['will'] ?? []);
        } elseif ($response === false) {
            if ($this->client->errCode === SOCKET_ECONNRESET) {
                $this->client->close();
            } elseif ($this->client->errCode !== SOCKET_ETIMEDOUT) {
                if ($this->isCoroutineClientType()) {
                    $errMsg = $this->client->errMsg;
                } else {
                    $errMsg = socket_strerror($this->client->errCode);
                }
                throw new RuntimeException($errMsg, $this->client->errCode);
            }
        } elseif (is_string($response) && strlen($response) > 0) {var_dump($response,'*========***');
            if ($this->config['protocol_level'] === ProtocolInterface::MQTT_PROTOCOL_LEVEL_5_0) {
                return ProtocolV5::unpack($response);
            }

            return Protocol::unpack($response);
        }

        return true;
    }

打印结果
string(4) " " string(12) "*========***" string(5) "" string(12) "*========***" string(18) "0 testtopic11111" string(12) "*========***" string(0) "" string(9) "*********" string(4) " " string(12) "*========***" string(2) "΢ string(12) "*========***" send ping success string(2) "΢ string(12) "*========***" send ping success string(0) "" string(9) "*********" string(4) " " string(12) "*========***" string(2) "΢ string(12) "*========***" send ping success
只要进入了重连,后面就接收不到主题消息

commented

如果你clean_session设置了true,自然是收不到的。 看下mqtt协议的clean_session作用

clean_session 主要是是否接收离线时主题消息,重连之后,我发布主题消息,监听还是接收不到

commented

image