1

I am using php-mqtt, and its working great. The below subscribe has no issues. It has a "loop forever" for the MQTT and it runs forever as it should. As devices connect, the setMqttLastConnectedAt() always works. But, the setMqttConnectedServer() only works for first few connections then stops updating. I thought it was the params, so that why I tried hardcoding the IP

$client->subscribe('/brokers/clients/#', function ($topic, $message) use ($io) {
    //        $message=json_decode($message);
                $device->setMqttConnectedServer('10.11.0.6');
//                $device->setMqttConnectedServer($this->params->get('mqttip'));
                $device->setMqttLastConnectedAt(new \DateTime());
                $this->em->persist($device);
                $this->em->flush();
            }

But, its quite odd that it works several times, then stops just that one set method. I removed some code for simplicity, for example the selecting of the device, because it clearly always gets it, for it to update the connected time.

So, why just this one column? And why does it work a few times, then stop?

If you can point me in where to debug, I'd be happy to try to solve myself.

rezshar
  • 570
  • 1
  • 6
  • 20
TDawg
  • 833
  • 2
  • 8
  • 24

1 Answers1

0

This isn't "really" an answer, but I thought I would post my workaround in case someone else had issues.

I made a Symfony Command using the Process Component. The server has an executable which returns a routing table of all the MQTT servers attached. I query it, then the script updates the row in database. I don't think its ideal, but it solves the issue.

TDawg
  • 833
  • 2
  • 8
  • 24