not sure to understand: isn't the runOnUiThread method used exactely for the opposite, I mean running operations on the main thread even when they are launched from a different one? I use it for example to modify a View on a thread different from the one that created the View (tipically the main one)
My Activity implements the MqttCallback interface, hence it has a messageArrived method that is called when a message arrives. How can I force the MQTT client to call this method from a thread different from the main one?
sergio
Date: Fri, 30 Nov 2012 11:49:10 +0100
From: petteri.hyttinen@xxxxxxxxx
To: paho-dev@xxxxxxxxxxx
Subject: Re: [paho-dev] Disconnect when receiving messages
Activity has a method called runOnUiThread(runnable)
Den 30 nov 2012 11:44 skrev "Sergio Torassa" <
sergio.torassa@xxxxxxxxxxx>:
Thanks to both.
@petteri: I also faced this problem and MqttClient.connect() and MqttTopic.publish are now on their own threads.
But how can you bind the reception of the message on a thread?
I
simply defined my Activity as "implements MqttCallback" and then I
added MqttClient.setCallback(MyActivity.this). Is it enough to put also
this code into its own thread or have I to do anything more?
sergio
From:
petteri.hyttinen@xxxxxxxxxDate: Fri, 30 Nov 2012 11:10:49 +0100
To:
paho-dev@xxxxxxxxxxxSubject: Re: [paho-dev] Disconnect when receiving messages
I had the same problem before!
The problem for me was that you can not run network operations in the Main thread (UI thread). You must make sure that Paho operation are performed in different thread or you will be disconnected when network traffic occurs.
// Petteri
the current version of the Paho Java should
work on Android with the caveats re location of where messages are stored.
I have not come across the problem you mention where the client is
disconnected when a message arrives. Does the error occur before
message arrived is called, during or after control is returned from it?
There are some updates in progress to
both fix a number of problems and add some enhancements to make it more
friendly to Android. The update will also have been through a rigorous
test on Android. Hoping to have this available in Dec.
All the best
Dave
From:
Sergio Torassa <sergio.torassa@xxxxxxxxxxx>
To:
"paho-dev@xxxxxxxxxxx"
<paho-dev@xxxxxxxxxxx>,
Date:
30/11/2012 09:30
Subject:
[paho-dev] Disconnect
when receiving messages
Sent by:
paho-dev-bounces@xxxxxxxxxxx
Hello everybody,
I'm trying to use the mqtt paho library in an Android application for usage
with a mosquitto server.
I eventually was able to solve all the issues wrt write permissions on
Android directories, uses-permissions in the manifest and so on, but now
each time the device receives a message, the client is disconnected with
a message on the mosquitto server like this
Socket read error on client 0001, disconnecting.
Then the client has to reconnect and possibly to re-subscribe to all its
topics.
My workaround is to re-connect and re-subscribe in the MqttCallback.ConnectionLost,
but it is of course only a workaround.
Has anybody found a similar issue in implementing paho library?
If needed I can provide my code, but it is a very basic implementation
of the paho client.
I add that the same issue is not present when I connect via other clients
(e.g., mosquitto). _______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev
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
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev