Comments (20)
Indeed, this lines are probably crap
Anyway, I assume this is the main reason https://developer.android.com/about/versions/oreo/background.html
Here is the discussion eclipse/paho.mqtt.android#281
I would love when someone would implement a solution with https://developer.android.com/reference/android/app/job/JobScheduler.html . I would approve immediate
from paho.mqtt.android.
Thanks for the reply. I didn't have an idea of the changes from Android 8 on.
It seems to me now that we can forget about long time TCP connections and about a reliable and instant MQTT transfer as well :(
from paho.mqtt.android.
Yes, this is the biggest problem in this library. Maybe I will fix it in the next few days, but I promise nothing
There is no reason to give up that early. You can switch back to
targetSdkVersion 24
then I expect to work properly.
But with this you can't publish to Google play store anymore
from paho.mqtt.android.
The thing is how to test it in Espresso test this background service behavior ?
from paho.mqtt.android.
@JiriBilek Your have to help me.
I following your connection String serverUri = "tcp://broker.hivemq.com:1883";
Does this works for you, or is it my network connection ? (I'm on vacation, and maybe the port it locked in my hotel)
from paho.mqtt.android.
In your example, I had to add to the manifest more privileges to be able to connect:
<!-- Permissions the Application Requires -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
from paho.mqtt.android.
In your example,
It's the example, not mine 😉 I just try to keep this library alive.
Please see #84 This solves only the init crash.
And yes there are too less permission, and unfortunately it's doesn't show any error when it's missing 👎
from paho.mqtt.android.
I tried the example on Android 5.1 and it lost the connection as well.
from paho.mqtt.android.
I try to reproduce it, but till now I failed.
This looks not that bad.
How does it looks like on your side ?
from paho.mqtt.android.
It looks the same. Between "The Connection was list" and "Reconnected" is losing the data from the broker.
The last line is confusing - failed connection because already connected. Weird.
I use QoS 0 as I my intention is to know about the event asap. I am monitoring a beehive (bumblebees, actually).
from paho.mqtt.android.
my intention is to know about the event asap
It has the touch of eclipse/paho.mqtt.android#281 (comment) Solution 1 with forground services
You battery will be empty sooner, but everything has a price
Anyway I tried to introduce a test to capture the error case with #98 and #96 and to be honest I need help here to first have 1 #reproduce able issue, then (only after this) I can look for a 2 #solution.
For a better understanding it comes with screenshots of test case
I'm stuck on 1 #reproduce able issue. You are warmly welcome to jump into this.
from paho.mqtt.android.
Yes, I read the comment about foreground services. It may solve my problem. It'll take me time as I must study the android services first. Until now, I took the paho.mqtt library as such and have not studied the internals in it.
As to the tests, I want to help but I don't understand what should I do.
from paho.mqtt.android.
As to the tests, I want to help but I don't understand what should I do.
I need to know, how to reproduce it.
Btw, the BasicDemo can send a message, but never receive it. -wtf-
from paho.mqtt.android.
Between "The Connection was list" and "Reconnected" is losing the data from the broker.
Did you changed the qos
(quality of service) ? Maybe it helps.
Btw, when you do your changes in a branch of your fork, I could at least follow what you did
from paho.mqtt.android.
Ok, I must leave now but in the afternoon I'll fork the repo and play with the qos.
from paho.mqtt.android.
I forked the repo, made necessary changes (JiriBilek@8eda6ae) and run it. It run without losing the connection for 30 minutes while the phone was connected to the usb for the whole time. Shortly after disconnecting the usb cable, it lost the connection.
Still Android 5.1.
Edit: I realized that with the USB power, my old app runs fine and holds the connection like a charm. Next, I'll try the same on Android 10.
Edit2: I checked out the AwakeTest and run it. As long as the phone was connected to the PC (and charging), it held the connection. After plugging out, the connection was lost.
from paho.mqtt.android.
Can my app receive the MQTT message even if the screen is turned off or my app is not the foreground app, with this library? The "basic sample" seems to be working, but that was with my app in the foreground with the screen on. My app would not be very useful if I have to keep the screen on and my app as the foreground app to receive the MQTT message.
If it is possible, would you add another simple sample project to show the incoming message in the system notification when the app is not the foreground app or the screen is turned off?
from paho.mqtt.android.
Without foreground service, you could give https://github.com/hannesa2/paho.mqtt.android/releases/tag/3.4.0-beta5 a try.
I uses Workmanager
to avoid to keep device always on.
from paho.mqtt.android.
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!
from paho.mqtt.android.
Closing this. Please reopen if you believe it should be addressed. Thank you for your contribution.
from paho.mqtt.android.
Related Issues (20)
- The foreground service types are required since Android 14 HOT 2
- Started service vs bound service HOT 10
- Calling disconnect twice results in crash HOT 1
- Exact alarm HOT 6
- Network change results in a NullPointerException. HOT 17
- Sending when not connected results in crash HOT 1
- connectionLostAction crash: MqttException cannot be cast to android.os.Parcelable HOT 2
- Interference with Filterable HOT 2
- toolbar overlapped with notfication bar HOT 3
- PROBLEM TO POPULATE TEXTVIEW WITH MESSAGE_ARRIVED HOT 2
- IllegalArgumentException for Android S+ Version HOT 4
- 在发送心跳时 cpu占用高 HOT 2
- BroadcastReceiver components are not allowed to bind to services HOT 4
- The play store console stated that am using FOREGROUND_SERVICE_DATA_SYNC even though I don't. HOT 8
- WorkManager version, WAKE_LOCK permission and Chucker Library HOT 5
- Long running tessts in sleep mode HOT 2
- Unexplained websocket disconnection precisely 5 minutes after the connection is established HOT 4
- Need Android 14 support - App Crashes HOT 2
- MQTT连接后androidx.work mqtt的消息也收不到 HOT 1
- android14设备,使用3.6.4,经常会断开连接,提示:已断开连接 (32109) - java.net.SocketException: Software caused connection abort
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paho.mqtt.android.