Skip to content

Invalid function arguments provided. client->loopForever() #108

@lifamomo

Description

@lifamomo

call this function client->loopForever() , Often appear Invalid function arguments provided
below is the code I wrote:

public function send($msg){
try {
$mid = 0;
$mqttclient = new \Mosquitto\Client;
$gateway_topic = $this->topic;
$mqttclient->onConnect(function() use ($mqttclient, $gateway_topic,&$mid,$msg)
{
$mid = $mqttclient->publish($gateway_topic,$msg,$this->qos,1);
$mqttclient->disconnect();
});
$mqttclient->setCredentials($this->username, $this->password);
$mqttclient->connect($this->server, $this->port, 5);
$mqttclient->loopforever();
} catch (Exception $e) {
writeException($e);
}
echo "success";
}

please help, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions