Closed imsanjaysah closed 4 years ago
OK, you seem to have demonstrated quite successfully that when using the PHP broker the client doesn't receive ping responses to its ping requests, this would suggest the PHP broker doesn't respect keep alive parameters in the connection message, or doesn't do keep alive at all or you have to enable it somehow.
You could check what version of MQTT you are using, you can set version 3.1 or 3.1.1 in the client depending on what broker you are using. I have seen some brokers get upset if this is set incorrectly for them although it usually causes more trouble than just upsetting the keepalive sequence.
At the end of the day you will need to inspect your PHP brokers logs to see what it is doing, you won't be able to diagnose this client side as its not as though we are receiving a message then not processing it correctly, its not being received at all there's nothing the client can do here.
@shamblett , Thank you for your prompt reply and your input. Really appreciate it. Will look into the PHP broker part as you suggested.
Thanks.
I am trying to communicate with a Php MQTT mosquitto broker. App gets connected and subscribed to topic successfully. But after sometime (~10 seconds) the client stops receiving data. Please refer the below log, it seems the ping response is not getting success.
I/flutter ( 5543): 2020-09-14 12:06:22.713007 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5543): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5543): 2020-09-14 12:06:42.722693 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5543): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5543): 2020-09-14 12:07:02.744093 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5543): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5543): 2020-09-14 12:07:22.757730 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5543): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
To identify root cause, I redirected the app to a Node mosquitto MQTT broker but using this broker this issue never occurred. Refer the below log. Now you can see the client receives the response for the ping request.
I/flutter ( 4738): 2020-09-14 12:02:41.643556 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 4738): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 4738): 2020-09-14 12:02:43.151154 -- MqttConnection::_onData
I/flutter ( 4738): 2020-09-14 12:02:43.151787 -- MqttServerConnection::_onData - message received MQTTMessage of type MqttMessageType.pingResponse
I/flutter ( 4738): Header: MessageType = MqttMessageType.pingResponse, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 4738): 2020-09-14 12:02:43.152233 -- MqttServerConnection::_onData - message available event fired
I/flutter ( 4738): 2020-09-14 12:02:43.152710 -- MqttConnectionHandlerBase::messageAvailable - message type is MqttMessageType.pingResponse
I/flutter ( 4738): 2020-09-14 12:03:01.665404 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 4738): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 4738): 2020-09-14 12:03:02.016785 -- MqttConnection::_onData
I/flutter ( 4738): 2020-09-14 12:03:02.017365 -- MqttServerConnection::_onData - message received MQTTMessage of type MqttMessageType.pingResponse
I/flutter ( 4738): Header: MessageType = MqttMessageType.pingResponse, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 4738): 2020-09-14 12:03:02.017724 -- MqttServerConnection::_onData - message available event fired
I/flutter ( 4738): 2020-09-14 12:03:02.018073 -- MqttConnectionHandlerBase::messageAvailable - message type is MqttMessageType.pingResponse
I want to understand why it's working fine with Node broker and not working with Php one. I also tested with MQTT chrome extension and it works fine but not in the app.
Looking forward for your help. Thanks in advance.