shamblett / mqtt_client

A server and browser based MQTT client for dart
Other
548 stars 176 forks source link

The MQTT subscription is successful, but I can't receive the message sent by the server. #113

Closed nodfe closed 5 years ago

nodfe commented 5 years ago

The connection was successful, but the message sent by the server could not be received client.updates.listen(_onData); _onData(List<MqttReceivedMessage<MqttMessage>> data) { print("GetMessage"); }

shamblett commented 5 years ago

Ok, I'm going to need log output from the client to look at this.

nodfe commented 5 years ago

Ok, I'm going to need log output from the client to look at this.

It did not report an error

D/DisplayManager( 3730): getDisplayInfo: displayId=0, info=DisplayInfo{"内置屏幕", uniqueId "local:0", app 1920 x 1032, real 1920 x 1080, largest app 1920 x 1847, smallest app 1080 x 1007, 59.804 fps, supportedRefreshRates [59.804], rotation 0, density 160 (159.89508 x 160.42105) dpi, layerStack 0, appVsyncOff 0, presDeadline 17721289, type BUILT_IN, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS}
D/DisplayManager( 3730): getDisplayInfo: displayId=0, info=DisplayInfo{"内置屏幕", uniqueId "local:0", app 1920 x 1032, real 1920 x 1080, largest app 1920 x 1847, smallest app 1080 x 1007, 59.804 fps, supportedRefreshRates [59.804], rotation 0, density 160 (159.89508 x 160.42105) dpi, layerStack 0, appVsyncOff 0, presDeadline 17721289, type BUILT_IN, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS}
Restarted application in 2,321ms.
D/DisplayManager( 3730): getDisplayInfo: displayId=0, info=DisplayInfo{"内置屏幕", uniqueId "local:0", app 1920 x 1032, real 1920 x 1080, largest app 1920 x 1847, smallest app 1080 x 1007, 59.804 fps, supportedRefreshRates [59.804], rotation 0, density 160 (159.89508 x 160.42105) dpi, layerStack 0, appVsyncOff 0, presDeadline 17721289, type BUILT_IN, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS}
I/flutter ( 3730): MQTT CONNECT SUCCESS
I/flutter ( 3730): MqttConnectReturnCode.connectionAccepted
I/flutter ( 3730): subscribed SUCCESS
I/flutter ( 3730): --subscribed, topic=213123-123-321-111
D/DisplayManager( 3730): getDisplayInfo: displayId=0, info=DisplayInfo{"内置屏幕", uniqueId "local:0", app 1920 x 1032, real 1920 x 1080, largest app 1920 x 1847, smallest app 1080 x 1007, 59.804 fps, supportedRefreshRates [59.804], rotation 0, density 160 (159.89508 x 160.42105) dpi, layerStack 0, appVsyncOff 0, presDeadline 17721289, type BUILT_IN, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS}
nodfe commented 5 years ago

Ok, I'm going to need log output from the client to look at this.

My connection operation is completed in the init state, the subscription operation is completed in the callback after the successful connection, and the message listener is completed in the callback after the subscription is successful.

shamblett commented 5 years ago

Yes, I can see you have connected and subscribed what I need is the mqtt_client log so I can see if a message has been received by the client and not delivered or not received, please turn on logging on the client itself

nodfe commented 5 years ago

Yes, I can see you have connected and subscribed what I need is the mqtt_client log so I can see if a message has been received by the client and not delivered or not received, please turn on logging on the client itself

ok, wait me a moment thks!

nodfe commented 5 years ago

Yes, I can see you have connected and subscribed what I need is the mqtt_client log so I can see if a message has been received by the client and not delivered or not received, please turn on logging on the client itself

This is And i try to send a message to client but client is not giv me any response

I/flutter ( 5012): 2019-09-06 16:18:47.497443 -- Authenticating with username '{app}' and password '{1}'
I/flutter ( 5012): 2019-09-06 16:18:47.565522 -- SynchronousMqttConnectionHandler::internalConnect entered
I/flutter ( 5012): 2019-09-06 16:18:47.565751 -- SynchronousMqttConnectionHandler::internalConnect - initiating connection try 0
I/flutter ( 5012): 2019-09-06 16:18:47.566412 -- SynchronousMqttConnectionHandler::internalConnect - insecure TCP selected
I/flutter ( 5012): 2019-09-06 16:18:48.931485 -- MqttConnection::_startListening
I/flutter ( 5012): 2019-09-06 16:18:48.952011 -- SynchronousMqttConnectionHandler::internalConnect sending connect message
I/flutter ( 5012): 2019-09-06 16:18:48.959901 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.connect
I/flutter ( 5012): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): Connect Variable Header: ProtocolName=MQIsdp, ProtocolVersion=3, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60
I/flutter ( 5012): Instance of 'MqttConnectPayload'
I/flutter ( 5012): 2019-09-06 16:18:49.020804 -- SynchronousMqttConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code noneSpecified
I/flutter ( 5012): 2019-09-06 16:18:49.040555 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:18:49.069478 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.connectAck
I/flutter ( 5012): Header: MessageType = MqttMessageType.connectAck, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 2
I/flutter ( 5012): Connect Variable Header: TopicNameCompressionResponse={0}, ReturnCode={MqttConnectReturnCode.connectionAccepted}
I/flutter ( 5012): 2019-09-06 16:18:49.080392 -- MqttConnection::_onData - message processed
I/flutter ( 5012): 2019-09-06 16:18:49.094093 -- SynchronousMqttConnectionHandler::_connectAckProcessor
I/flutter ( 5012): 2019-09-06 16:18:49.094597 -- SynchronousMqttConnectionHandler::_connectAckProcessor - state = connected
I/flutter ( 5012): 2019-09-06 16:18:49.095500 -- SynchronousMqttConnectionHandler:: cancelling connect timer
I/flutter ( 5012): 2019-09-06 16:18:49.097127 -- SynchronousMqttConnectionHandler::internalConnect - post sleep, state = Connection status is connected with return code connectionAccepted
I/flutter ( 5012): 2019-09-06 16:18:49.097548 -- SynchronousMqttConnectionHandler::internalConnect exited with state Connection status is connected with return code connectionAccepted
I/flutter ( 5012): MQTT CONNECT SUCCESS
I/flutter ( 5012): 2019-09-06 16:18:49.336797 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.subscribe
I/flutter ( 5012): Header: MessageType = MqttMessageType.subscribe, Duplicate = false, Retain = false, Qos = MqttQos.atLeastOnce, Size = 0
I/flutter ( 5012): Subscribe Variable Header: MessageIdentifier={1}
I/flutter ( 5012): Payload: Subscription [{1}]
I/flutter ( 5012): {{ Topic={213123-123-321-111}, Qos={MqttQos.atMostOnce} }}
I/flutter ( 5012): 
I/flutter ( 5012): MqttConnectReturnCode.connectionAccepted
I/flutter ( 5012): 2019-09-06 16:18:49.552929 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:18:49.558320 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.subscribeAck
I/flutter ( 5012): Header: MessageType = MqttMessageType.subscribeAck, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 3
I/flutter ( 5012): SubscribeAck Variable Header: MessageIdentifier={1}
I/flutter ( 5012): Payload: Qos grants [{1}]
I/flutter ( 5012): {{ Grant={MqttQos.atMostOnce} }}
I/flutter ( 5012): 
I/flutter ( 5012): 2019-09-06 16:18:49.558645 -- MqttConnection::_onData - message processed
I/flutter ( 5012): subscribed SUCCESS
I/flutter ( 5012): --subscribed, topic=213123-123-321-111
This is taking longer than expected...
nodfe commented 5 years ago

Yes, I can see you have connected and subscribed what I need is the mqtt_client log so I can see if a message has been received by the client and not delivered or not received, please turn on logging on the client itself

This is And i try to send a message to client but client is not giv me any response

I/flutter ( 5012): 2019-09-06 16:18:47.497443 -- Authenticating with username '{app}' and password '{1}'
I/flutter ( 5012): 2019-09-06 16:18:47.565522 -- SynchronousMqttConnectionHandler::internalConnect entered
I/flutter ( 5012): 2019-09-06 16:18:47.565751 -- SynchronousMqttConnectionHandler::internalConnect - initiating connection try 0
I/flutter ( 5012): 2019-09-06 16:18:47.566412 -- SynchronousMqttConnectionHandler::internalConnect - insecure TCP selected
I/flutter ( 5012): 2019-09-06 16:18:48.931485 -- MqttConnection::_startListening
I/flutter ( 5012): 2019-09-06 16:18:48.952011 -- SynchronousMqttConnectionHandler::internalConnect sending connect message
I/flutter ( 5012): 2019-09-06 16:18:48.959901 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.connect
I/flutter ( 5012): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): Connect Variable Header: ProtocolName=MQIsdp, ProtocolVersion=3, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60
I/flutter ( 5012): Instance of 'MqttConnectPayload'
I/flutter ( 5012): 2019-09-06 16:18:49.020804 -- SynchronousMqttConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code noneSpecified
I/flutter ( 5012): 2019-09-06 16:18:49.040555 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:18:49.069478 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.connectAck
I/flutter ( 5012): Header: MessageType = MqttMessageType.connectAck, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 2
I/flutter ( 5012): Connect Variable Header: TopicNameCompressionResponse={0}, ReturnCode={MqttConnectReturnCode.connectionAccepted}
I/flutter ( 5012): 2019-09-06 16:18:49.080392 -- MqttConnection::_onData - message processed
I/flutter ( 5012): 2019-09-06 16:18:49.094093 -- SynchronousMqttConnectionHandler::_connectAckProcessor
I/flutter ( 5012): 2019-09-06 16:18:49.094597 -- SynchronousMqttConnectionHandler::_connectAckProcessor - state = connected
I/flutter ( 5012): 2019-09-06 16:18:49.095500 -- SynchronousMqttConnectionHandler:: cancelling connect timer
I/flutter ( 5012): 2019-09-06 16:18:49.097127 -- SynchronousMqttConnectionHandler::internalConnect - post sleep, state = Connection status is connected with return code connectionAccepted
I/flutter ( 5012): 2019-09-06 16:18:49.097548 -- SynchronousMqttConnectionHandler::internalConnect exited with state Connection status is connected with return code connectionAccepted
I/flutter ( 5012): MQTT CONNECT SUCCESS
I/flutter ( 5012): 2019-09-06 16:18:49.336797 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.subscribe
I/flutter ( 5012): Header: MessageType = MqttMessageType.subscribe, Duplicate = false, Retain = false, Qos = MqttQos.atLeastOnce, Size = 0
I/flutter ( 5012): Subscribe Variable Header: MessageIdentifier={1}
I/flutter ( 5012): Payload: Subscription [{1}]
I/flutter ( 5012): {{ Topic={213123-123-321-111}, Qos={MqttQos.atMostOnce} }}
I/flutter ( 5012): 
I/flutter ( 5012): MqttConnectReturnCode.connectionAccepted
I/flutter ( 5012): 2019-09-06 16:18:49.552929 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:18:49.558320 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.subscribeAck
I/flutter ( 5012): Header: MessageType = MqttMessageType.subscribeAck, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 3
I/flutter ( 5012): SubscribeAck Variable Header: MessageIdentifier={1}
I/flutter ( 5012): Payload: Qos grants [{1}]
I/flutter ( 5012): {{ Grant={MqttQos.atMostOnce} }}
I/flutter ( 5012): 
I/flutter ( 5012): 2019-09-06 16:18:49.558645 -- MqttConnection::_onData - message processed
I/flutter ( 5012): subscribed SUCCESS
I/flutter ( 5012): --subscribed, topic=213123-123-321-111
This is taking longer than expected...
I/flutter ( 5012): 2019-09-06 16:19:47.553147 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:19:47.578503 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:19:47.581176 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.pingResponse
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingResponse, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:19:47.581914 -- MqttConnection::_onData - message processed
I/flutter ( 5012): 2019-09-06 16:20:47.557679 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:20:47.571346 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:20:47.572359 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.pingResponse
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingResponse, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:20:47.573051 -- MqttConnection::_onData - message processed
I/flutter ( 5012): 2019-09-06 16:21:47.562279 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:21:47.581121 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:21:47.582063 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.pingResponse
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingResponse, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:21:47.582856 -- MqttConnection::_onData - message processed
I/flutter ( 5012): 2019-09-06 16:22:47.567328 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:22:47.597173 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:22:47.598111 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.pingResponse
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingResponse, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:22:47.598738 -- MqttConnection::_onData - message processed
I/flutter ( 5012): 2019-09-06 16:23:47.572309 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:23:47.598910 -- MqttConnection::_onData
I/flutter ( 5012): 2019-09-06 16:23:47.599772 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.pingResponse
I/flutter ( 5012): Header: MessageType = MqttMessageType.pingResponse, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5012): 2019-09-06 16:23:47.600414 -- MqttConnection::_onData - message processed
shamblett commented 5 years ago

The second log is the ping keepalive, this is normal, the first log shows that nothing is being received from the broker for your subscribed topic, hence nothing is being delivered, check the topics on the broker and the broker logs for more info.

nodfe commented 5 years ago

The second log is the ping keepalive, this is normal, the first log shows that nothing is being received from the broker for your subscribed topic, hence nothing is being delivered, check the topics on the broker and the broker logs for more info.

i solved this problem , the background not send message for me. its so bad thanks.

shamblett commented 5 years ago

Ok, closing this then.