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

Hi Charles,

I just reconnect when the connectionLost event comes in:


  method connectionLost(t=Throwable)
    do
    connectAndSubscribe()
    catch mqx=MqttException
      log(mqx.getMessage())
    end


(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://10.18.93.54:1883", "charles_subscribe");
>        MqttConnectOptions opts = new MqttConnectOptions();
>        opts.setKeepAliveInterval(10);
>        opts.setCleanSession(true);
> 
>        client.setCallback(this);
>        client.connect(opts);
>        client.subscribe(topic);
> 
>        try {
>            System.in.read();
>        } 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
> http://dev.eclipse.org/mailman/listinfo/paho-dev



Back to the top