0

M2mqtt incorporate in my asp.net mvc project. Face problem to synch subscribe informations. enter image description here When more than one clients published on one specific topic, client can subscribe them easily.

suppose in one situation when published happen then client is down/offline when he alive then only get the last published message not all published messages. What to do?Is it a problem on MQTT?How alive client get all published messages.

M2mqtt connection with broker use by bellow syntax

 public static MqttClient SmartHomeMQTT { get; set; }

  SmartHomeMQTT = new MqttClient(brokerAddress, MqttSettings.MQTT_BROKER_DEFAULT_SSL_PORT, true, new X509Certificate(Resource.ca), null, MqttSslProtocols.TLSv1_2, client_RemoteCertificateValidationCallback);
  SmartHomeMQTT.Connect("6ea592c5-4b2f-481a-bb0a-eccbe8579d14", "####", "####", false, 3600);

**Note:**Connect method parameter four set to false for clean_session property but it's not work.

shamim
  • 6,640
  • 20
  • 85
  • 151
  • Take a look at [this question](http://stackoverflow.com/q/32967754/423955), answer and comments. Try setting `clean_session` flag to false, use the same client-id on reconnect, publish messages using QoS 1 or 2. – Alessandro Da Rugna Feb 23 '16 at 08:31

1 Answers1

0

To ensure that subscribers receive all messages, even ones that are published when they are offline (known as message persistence), you need to do a few things:

  1. Make sure that 'Clean Session' is turned off in the subscribers
  2. Ensure that each subscriber is using a unique Client ID
  3. Use a QoS of 1 or 2

You don't say which MQTT server you are using, but you need to ensure that the server implementation supports it too.

njh
  • 783
  • 3
  • 15
  • thanks for your reply. I used bellow syntax as you say but it's not working.Please check my updated question description – shamim Feb 23 '16 at 10:29