Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Troubleshooting persistent connection issues with Paho and Android

Roger,

I haven't checked within the last week or so, but prior to that I never saw these issues on the mosquitto_sub client.  That client would receive the message right away, and only once.  On the app-side, I would receive a torrent of messages after I sent a message, most of them having been received already.  Granted, the mosquitto_sub was always run on the same machine as the broker, might that have influenced it?

I've also tried monitoring the connection using a third-party MQTT client I found on the Google Play store.  While it seems to also be a little delayed at times, or in need of refreshing the connection, I never noticed any duplication (though that could be handling of duplicate messages on their part).

Best and regards,

Tucker


On Mon, Dec 23, 2013 at 10:22 AM, Roger Light <roger@xxxxxxxxxx> wrote:
Hi Tucker,

I can't comment on the Java side of things, but have you seen the
problems with delayed and duplicated messages using a different
client? Do you see duplicate QoS 2 messages using mosquitto_sub for
example?

Cheers,

Roger

On Mon, Dec 23, 2013 at 2:14 PM, Tucker Vento <tuckervento@xxxxxxxxx> wrote:
> Hey guys,
>
> I communicated with some of you about a month ago regarding issues I was
> having using the Paho API in an Android app I was working on; since then,
> I've managed to get messages to deliver and everything is working a lot
> better.  I switched to using an EC2 instance as my broker instead of my own
> server (still using Mosquitto though) and that seemed to fix it...I'm not
> sure why.  Either way, the main issue I'm having now is that messages only
> deliver from the broker to the client after the client sends something to
> the broker.  Do I need to continually ping the server while the app is
> running in the foreground?  I know the Facebook Messenger app uses MQTT, so
> I thought that the client should be able to receive messages on demand of
> the broker, not only at a time when the client seeks them out.
>
> In addition, I'm getting LOADS of duplicate messages.  All my messages are
> sent with a QoS of 2, so I thought that shouldn't happen...Either way, I put
> in some checks against duplicate messages getting added to my app's data
> model, so they aren't really causing a problem besides wasted data and
> runtime.  Still, if it's a problem I can fix I would really like to.
>
> Below I'll include some of the Paho-relevant code from the app.  On my
> mosquitto.conf file, I'm using user/password authentication and allowing for
> 10 in-flight messages at a time (I intended to included more from the conf
> file in here, but I'm having trouble ftp-ing into my server from work...I
> can attach it later if it would help).  Sorry for the extreme length!  If
> you have any advice as to where this problem might be coming from, or if
> there's anything I could debug through that would give more information,
> please let me know!  Thank you!!
>
> Connection set up:
>
> public void setUpService(final Context p_context){
> ........
>         try {
>             _mqttClient = new MqttAsyncClient(_mqttServer, _clientId, new
> MqttDefaultFilePersistence(p_context.getFilesDir().getAbsolutePath()));
>             _mqttClient.setCallback(this);
>             _mqttOptions.setUserName(_mqttUserName);
>             _mqttOptions.setPassword(_mqttPassword.toCharArray());
>             _mqttOptions.setCleanSession(false);
>             _mqttOptions.setKeepAliveInterval(_keepAlive);
>             _mqttOptions.setConnectionTimeout(_connectionTimeout);
>             IMqttToken token = _mqttClient.connect(_mqttOptions);
>             token.waitForCompletion();
>             IMqttToken token2 = _mqttClient.subscribe("us", 2);
>             token2.waitForCompletion();
>         } catch (MqttException e) {
>             handleMqttException(e);
>         }
>         ......
>     }
>
> Publishing override:
>
> private void publishMessage(TransmissionPayload p_payload){
>         if (!_mqttClient.isConnected()){
>             try {
>                 IMqttToken token = _mqttClient.connect(_mqttOptions);
>                 token.waitForCompletion();
>             } catch (MqttException e) { handleMqttException(e); }
>         }
>
>         JSONObject tx = new JSONObject(p_payload.getMap());
>
> ((NotificationManager)getSystemService(NOTIFICATION_SERVICE)).cancelAll();
>
>         try {
>             _mqttClient.publish(_topic, tx.toString().getBytes(_encoding),
> 2, false);
>         } catch (MqttException e) { handleMqttException(e); } catch
> (UnsupportedEncodingException e) {
>             e.printStackTrace();
>         }
>     }
>
> ***For clarification, _topic = "us", _keepAlive = 36000, _connectionTimeout
> = 30.
>
> Thanks again for reading, and in advance for any of your help!
>
> Regards,
> Tucker
>
> --
> Tucker
>
> /* https://soundcloud.com/white-tuxedo */
>
> _______________________________________________
> paho-dev mailing list
> paho-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/paho-dev
>
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/paho-dev



--
Tucker

Back to the top