Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Mqtt Paho - Trying to publish while broker is unreachable

You could also use something like Redis as a local lightweight queueing mechanism for temporary storage / buffering while the network is down.

On Wed, Jan 22, 2014 at 9:32 AM, Ian Craggs <icraggs@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi Pablo,

the short answer is that you have to handle the situation by yourself.   Having some buffering capability in the client is something that you are not alone in asking for.  I'll make sure to add that to our requirements.

One way you can address this, is, as you point out, with a local Mosquitto broker and a bridge.


On 21/01/14 21:31, Pablo Lopez wrote:

Hi all paho-dev members.

This is my first (baby) step in the "Internet of things" world, and I'm having a hard time with it :)

Let me introduce myself : I'm Pablo, a french developer who is trying to connect raspberry pi sensors to a central server to process sensors values. 

But I'm having a hard time handling WiFi instability in my environment.

So I'm copying here a message I already put in the open on StackOverflow

Thank you for any help you could provide.

I'm going back to the Java Paho source code to try answering my question by myself ;)

I'm begininng to use Mqtt and I have a hard time with handling an unreliable network. I'm using a Paho Java Client (in groovy) to publish messages to a distant Mosquitto Broker.

Is there a way, when the broker is unreachable, to have the Paho client persist the message and automatically re-connect to the broker and publish the locally stored messages ? Do I have to handle everything myself, using for example a local broker ?

Here is my client building code

    String pe
Dir = config['persistence-dir'] ?: System.getProperty('')
    def persistence = new MqttDefaultFilePersistence(persistenceDir)
    client = new MqttClient(uri, clientId, persistence)
    options = new MqttConnectOptions()
    if (config.password) {
        options.setPassword(config.password as 

And my publish code

  def message = new MqttMessage(Json.encode(outgoingMessage).getBytes())
    try {
    def topic = client.getTopic('processMsg')
    def token = topic.publish(message)
    if (client) {


Pablo Lopez
email & gtalk : plopez@xxxxxxxx / mob: +33-
Xebia, Software Development Done Right.

paho-dev mailing list

paho-dev mailing list

Andy Piper | Kingston upon Thames, London (UK)
blog:   |   skype: andypiperuk
twitter: @andypiper  |  images:

Back to the top