Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Client be disconnected when keepAliveInterval more than 10 secs

The Paho Java Client should keep the connection alive by sending pings every keepalive interval if no other messages flow.  If the network is in good shape and the sever is running correctly it should stay connected forever.  Is Mosquitto putting out an error stating it has killed the client as it has not received any packets from the client?  If that is the case it could be a bug in the Java client.  It is always 5 mins that the client is disconnected?

Can you raise a bug on bugzilla against paho here with full details?   Paho bugzilla site can be found here:

Per Rene it is a good idea to code the connectionLost call back to handle the case when a client disconnects abnormally e.g. blip in the network....


From:        René Jansen <rvjansen@xxxxxxxxx>
To:        General development discussions for paho project <paho-dev@xxxxxxxxxxx>,
Date:        25/10/2012 13:06
Subject:        Re: [paho-dev] Client be disconnected when keepAliveInterval more        than 10 secs
Sent by:        paho-dev-bounces@xxxxxxxxxxx

Hi Charles,

I just reconnect when the connectionLost event comes in:

 method connectionLost(t=Throwable)
   catch mqx=MqttException

(this is NetRexx source but you get the picture).

best regards,

René Jansen.

On 25 okt. 2012, at 13:01, Charles Wang | 王晨 <kitta4587@xxxxxxxxx> wrote:

> I tried Mosquitto and ActiveMQ, the code is simple:
>        MqttClient client = new MqttClient("tcp://", "charles_subscribe");
>        MqttConnectOptions opts = new MqttConnectOptions();
>        opts.setKeepAliveInterval(10);
>        opts.setCleanSession(true);
>        client.setCallback(this);
>        client.connect(opts);
>        client.subscribe(topic);
>        try {
>  ;
>        } catch (IOException e) {
>            //If we can't read we'll just exit
>        }
>        // Disconnect the client
>        client.disconnect();
> When keepAliveInterval more than 10 secs, the server will kill the connection after about 5 mins.
> But the Mosquitto library for C is worked.
> _______________________________________________
> paho-dev mailing list
> paho-dev@xxxxxxxxxxx

paho-dev mailing list

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Back to the top