transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

Plugin can't sync with the server, when it was stopped and then started again #239

Closed iveremeychuk closed 7 years ago

iveremeychuk commented 7 years ago

Your Environment

Expected Behavior

In the background plugin should send coordinates every time

Actual Behavior

When application was stopped after 2 minuts in stationary and then I continued to move a locations was saved on device, but on Sync to the server I got error like dat "No internet connection" The same behavior on your SampleApp application, I tested it

Steps to Reproduce

  1. Start plugin and move
  2. Stay 2 minutes
  3. Move again
christocracy commented 7 years ago

Logs please.

iveremeychuk commented 7 years ago

12-14 22:41:01.164 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:41:01.211 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:41:01.218 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:41:02.137 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1005 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=50 et=+4h3m36s648ms]

12-14 22:41:02.166 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired motionchange position 12-14 22:41:02.192 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:41:02.211 DEBUG [TSLocationManager incrementOdometer] 212.18811 12-14 22:41:02.242 INFO [TSLocationManager requestLocationUpdates] 🎾 Location-services: ON 12-14 22:41:02.263 INFO [SQLiteLocationDAO persist] ✅ INSERT: df0bc86e-6bd6-4556-b30e-f1dc01412b59 12-14 22:41:02.272 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=50 et=+4h3m36s795ms]

12-14 22:41:02.272 DEBUG [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service ╠═════════════════════════════════════════════

12-14 22:41:02.283 DEBUG [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service ╠═════════════════════════════════════════════

12-14 22:41:02.285 DEBUG [TSLocationManager onLocationResult] ╔═════════════════════════════════════════════ ║ Process LocationResult ╠═════════════════════════════════════════════

12-14 22:41:02.302 DEBUG [SQLiteLocationDAO first] ✅ Locked 1 records 12-14 22:41:02.306 DEBUG [TSLocationManager onLocationResult] ℹ️ IGNORED: same as last location 12-14 22:41:02.312 INFO [HttpService createRequest] 🔵 POST: df0bc86e-6bd6-4556-b30e-f1dc01412b59 12-14 22:41:02.626 INFO [HttpRequest parseNetworkResponse] 🔵 Response: 200 12-14 22:41:02.656 DEBUG [SQLiteLocationDAO destroy] ✅ DESTROY: df0bc86e-6bd6-4556-b30e-f1dc01412b59 12-14 22:41:06.577 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:41:06.603 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:41:06.614 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:41:16.512 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:41:16.548 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:41:16.558 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:41:25.456 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:41:25.481 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:41:25.487 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:41:34.318 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:41:34.351 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:41:34.358 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:41:43.349 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:41:43.383 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:41:43.391 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:41:52.184 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:41:52.220 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:41:52.232 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:42:01.103 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:42:01.132 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:42:01.140 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 1 12-14 22:42:09.973 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:42:10.006 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:42:10.014 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 1 12-14 22:42:15.155 DEBUG [LocationService onStopTimeout] 12-14 22:42:15.180 DEBUG [BackgroundGeolocationService onStopTimeout] 🔵 Stop-timeout elapsed! 12-14 22:42:15.202 INFO [BackgroundGeolocationService a] 🔵 setPace: true → false 12-14 22:42:15.210 INFO [TSLocationManager removeLocationUpdates] 🔴 Location-services: OFF 12-14 22:42:15.257 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1006 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=22 et=+4h4m49s778ms]

12-14 22:42:15.282 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired motionchange position 12-14 22:42:15.291 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:42:15.326 INFO [SQLiteLocationDAO persist] ✅ INSERT: f8dce1c5-219f-4254-b76f-3b41b5ba973e 12-14 22:42:15.347 DEBUG [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service ╠═════════════════════════════════════════════

12-14 22:42:15.371 DEBUG [SQLiteLocationDAO first] ✅ Locked 1 records 12-14 22:42:15.384 INFO [HttpService createRequest] 🔵 POST: f8dce1c5-219f-4254-b76f-3b41b5ba973e 12-14 22:42:18.982 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:42:19.035 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:42:27.861 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:42:27.877 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:42:36.713 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:42:36.765 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:42:45.664 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:42:45.694 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:42:54.493 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:42:54.525 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:43:03.332 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:43:03.373 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:43:12.199 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:43:12.247 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:43:16.458 DEBUG [HttpService onRequestError] ⚠️ HTTP Response: 0; java.net.ConnectException: failed to connect to /192.168.10.102 (port 82) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused) 12-14 22:43:16.513 DEBUG [SQLiteLocationDAO unlock] ✅ UNLOCKED: f8dce1c5-219f-4254-b76f-3b41b5ba973e 12-14 22:43:21.137 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:43:21.174 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:43:30.211 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:43:30.247 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:43:39.152 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:43:39.166 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:43:47.956 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:43:47.970 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:43:56.771 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:43:56.792 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:05.208 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:44:05.245 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:14.073 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:44:14.105 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:22.944 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:44:22.974 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:31.972 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:44:32.010 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:40.826 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:44:40.847 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:43.791 INFO [BackgroundGeolocationService a] 🔵 setPace: false → true 12-14 22:44:43.806 INFO [BackgroundGeolocationService i] 🔴 Stop heartbeat 12-14 22:44:44.078 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1007 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=50 et=+4h7m18s586ms]

12-14 22:44:44.123 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:44:47.567 INFO [BackgroundGeolocationService a] 🔵 setPace: true → true 12-14 22:44:47.689 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1008 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=50 et=+4h7m22s164ms]

12-14 22:44:47.731 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:44:47.881 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:44:47.891 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:47.902 INFO [BackgroundGeolocationService onActivityRecognitionResult] 🔵 Stop-timeout timer initiated (1 min)... 12-14 22:44:49.175 INFO [BackgroundGeolocationService a] 🔵 setPace: true → true 12-14 22:44:49.248 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1009 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=50 et=+4h7m23s763ms]

12-14 22:44:49.259 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:44:51.241 INFO [BackgroundGeolocationService a] 🔵 setPace: true → true 12-14 22:44:51.398 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1010 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=50 et=+4h7m25s916ms]

12-14 22:44:51.425 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:44:54.720 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1010 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=22 et=+4h7m29s192ms]

12-14 22:44:54.772 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired current position 12-14 22:44:54.795 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:44:54.806 DEBUG [TSLocationManager incrementOdometer] 212.18811 12-14 22:44:54.841 INFO [SQLiteLocationDAO persist] ✅ INSERT: 0fef4b8e-9be1-4784-bf4c-f4cfa878f3c7 12-14 22:44:54.859 DEBUG [HttpService flush] ╔═════════════════════════════════════════════ ║ HTTP Service ╠═════════════════════════════════════════════

12-14 22:44:54.877 DEBUG [SQLiteLocationDAO first] ✅ Locked 1 records 12-14 22:44:54.884 INFO [HttpService createRequest] 🔵 POST: f8dce1c5-219f-4254-b76f-3b41b5ba973e 12-14 22:44:55.008 INFO [BackgroundGeolocationService a] 🔵 setPace: true → true 12-14 22:44:55.045 DEBUG [LocationService onLocation] ╔═════════════════════════════════════════════ ║ LocationService: location:1011 ╠═════════════════════════════════════════════ ╟─ 📍 Location[fused 56,847219,60,604280 acc=22 et=+4h7m29s566ms]

12-14 22:44:55.055 INFO [TSLocationManager onSingleLocationResult] 🔵 Acquired current position 12-14 22:44:55.063 DEBUG [TSLocationManager calculateMedianAccuracy] 50.0 12-14 22:44:55.076 DEBUG [TSLocationManager incrementOdometer] 212.18811 12-14 22:44:55.109 INFO [SQLiteLocationDAO persist] ✅ INSERT: 57ebdd7f-f064-4125-9af0-d17e931b8ba8 12-14 22:44:55.126 INFO [HttpService flush] ℹ️ HttpService is busy 12-14 22:44:55.204 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:44:55.214 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:44:55.222 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:44:55.915 DEBUG [HttpService onRequestError] ⚠️ HTTP Response: 0; java.net.ConnectException: failed to connect to /192.168.10.102 (port 82) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused) 12-14 22:44:55.943 DEBUG [SQLiteLocationDAO unlock] ✅ UNLOCKED: f8dce1c5-219f-4254-b76f-3b41b5ba973e 12-14 22:45:04.038 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:45:04.071 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:45:04.081 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:45:12.887 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:45:12.907 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:45:12.917 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:45:21.763 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:45:21.849 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:45:21.861 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:45:32.498 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:45:32.605 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:45:32.613 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:45:41.367 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:45:41.391 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:45:41.398 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 0 12-14 22:45:50.366 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] still (100%) 12-14 22:45:50.433 DEBUG [BackgroundGeolocation isMainActivityActive] YES 12-14 22:45:50.462 DEBUG [BackgroundGeolocationService onActivityRecognitionResult] ℹ️ Waiting for stopTimeout (1 min): elapsed min: 1

christocracy commented 7 years ago
⚠️ HTTP Response: 0; java.net.ConnectException: failed to connect to /192.168.10.102 (port 82) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused)

This is not the plugin returning this HTTP response, it's Volley, the de-facto standard Android HTTP library.

iveremeychuk commented 7 years ago

I am sure, because when I back application to foreground and sync, all my requests was pushed to the server successfully. I tested on your sampleApp and I have the same issue with https://requestb.in/ service as a server side. Can you explain please how I can get a logs from SampleApp and I will provide it for you?

christocracy commented 7 years ago

It's related to your network and/or device.

christocracy commented 7 years ago

The error message is very clear:

⚠️ HTTP Response: 0; java.net.ConnectException: failed to connect to /192.168.10.102 (port 82) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused)
christocracy commented 7 years ago

Closing for lack of feedback.

ghost commented 7 years ago

I have the same issue.

MY ENV

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.6
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.10.1
Xcode version: Xcode 8.3.2 Build version 8E2002

PLUGIN DEV CONFIG

debug: true,
desiredAccuracy: 0,
distanceFilter: 0,
locationUpdateInterval: 10000,
disableStopDetection: true,
foregroundService: true,
stopOnTerminate: false,
extras: { imei: this.imei },
url: 'http://192.168.1.33:8000/mobile/location',
autoSync: true

CONFIRMED ON

Xiaomi Redmi 3 Pro @ Android 5.1.1

STEPS TO REPRODUCE

  1. Start an app Location Service starts fine; HTTP Service sends POST's to API server;
  2. Send app to background (not terminate) Location Service still gathers location info; HTTP Service still sends POST's to API server;
  3. Lock the device so the screen turns off Locations Service still works as expected (according to logs); HTTP Service just stops trying to send POST's;
  4. Unlock device Location Service still ok; HTTP Service will attempt to POST accumulated location data, but... HTTP Response: 0; java.net.ConnectException: failed to connect to
  5. Bring app to foreground HTTP Service now can send POST's successfuly.

API Server state is not changing in any way. It always accepts the requests (made from another apps). On my device Wi-Fi never disconnects.

LOG SAMPLE

05-06 15:03:31.342 7875-32391/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.LocationService onLocation] 
                                                                                       ╔═════════════════════════════════════════════
                                                                                       ║ LocationService: location
                                                                                       ╠═════════════════════════════════════════════
                                                                                       ╟─ ��  Location[fused 55,425025,37,775084 acc=53 et=+7d5h34m57s596ms]
05-06 15:03:31.362 7875-32391/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult] 
                                                                                       ╔═════════════════════════════════════════════
                                                                                       ║ Process LocationResult
                                                                                       ╠═════════════════════════════════════════════
05-06 15:03:31.372 7875-32391/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] 60.932
05-06 15:03:31.382 7875-32391/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.l.TSLocationManager incrementOdometer] 817.8954
05-06 15:03:31.412 7875-7875/com.ionicframework.nelomobile241382 D/SystemWebChromeClient: file:///android_asset/www/build/main.js: Line 35703 : [object Object]
05-06 15:03:31.412 7875-7875/com.ionicframework.nelomobile241382 I/chromium: [INFO:CONSOLE(35703)] "[object Object]", source: file:///android_asset/www/build/main.js (35703)
05-06 15:03:31.422 7875-32394/com.ionicframework.nelomobile241382 I/TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist] 
                                                                                         ✅  INSERT: b51b4555-de96-4e2e-99d8-6a3ec9a758d8
05-06 15:03:31.442 7875-32394/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.http.HttpService flush] 
                                                                                       ╔═════════════════════════════════════════════
                                                                                       ║ HTTP Service
                                                                                       ╠═════════════════════════════════════════════
05-06 15:03:31.482 7875-32394/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first] 
                                                                                         ✅  Locked 1 records
05-06 15:03:31.492 7875-32394/com.ionicframework.nelomobile241382 I/TSLocationManager: [c.t.l.http.HttpService createRequest] 
                                                                                         ��  POST: 2012ae54-64c7-45da-b1cf-1e5b3fe30145
05-06 15:03:32.522 7875-7875/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.http.HttpService onRequestError] 
                                                                                        ⚠️  HTTP Response: 0; java.net.ConnectException: failed to connect to /192.168.1.33 (port 8000) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused)
05-06 15:03:32.542 7875-7875/com.ionicframework.nelomobile241382 D/TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO unlock] 
                                                                                        ✅  UNLOCKED: 2012ae54-64c7-45da-b1cf-1e5b3fe30145
christocracy commented 7 years ago

Can you reproduce this using the background-geolocation-console as your server? Takes < minute to install. It will run on port 9000

ghost commented 7 years ago

I have already done it. The same picture there. The problem is not related to API endpoint...

christocracy commented 7 years ago

Can you try with a different device? I cannot reproduce this on any of my devices.

ghost commented 7 years ago

Maybe I can upgrade OS on my device. Can you provide some Android version where there is no issue with?

christocracy commented 7 years ago

The plugin works with Android 4.3+

christocracy commented 7 years ago

The plugin uses Android Volley library for HTTP. This is the standard HTTP library for Android.

christocracy commented 7 years ago

Change your url to http://posttestserver.com/post.php?dir=tephro. This is a generic "HTTP Post Dumping Server" that will accept posts from anything.

christocracy commented 7 years ago

Also of note, the OP's device and OS are similar to yours:

OS version: 5.0.2
Device manufacturer / model: Xaiomi Redmi note 2

My guess is it's related to Xaiomi devices hitting a server on same local network.

ghost commented 7 years ago

403 at posttestserver. Never mind. I'll try to update OS and see if any changes. I'll let you know. Thanks.

christocracy commented 7 years ago

Well, 403 is better than connection refused.

ghost commented 7 years ago

No, actually. Because it happens at first request, before I reproduce the issue =)

christocracy commented 7 years ago

posttestserver seems to have a rate-limiter now. It lets a few posts go through before I get 403

05-06 09:24:04.943  2586  2586 D TSLocationManager:   ✅  Locked 1 records
05-06 09:24:04.951  2586  2586 I TSLocationManager: [c.t.l.http.HttpService createRequest]
05-06 09:24:04.951  2586  2586 I TSLocationManager:   🔵  POST: 3d528f33-6a09-4cbb-9bba-ab5ab6558b27
05-06 09:24:05.212  2586  2726 I TSLocationManager: [c.t.l.http.HttpRequest parseNetworkResponse]
05-06 09:24:05.212  2586  2726 I TSLocationManager:   🔵  Response: 200
05-06 09:24:05.224  2586  2726 D TSLocationManager: [c.t.l.http.HttpRequest parseNetworkResponse]
05-06 09:24:05.224  2586  2726 D TSLocationManager:   ℹ️  No JSON found in server response
05-06 09:24:05.239  2586  2586 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO destroy]
05-06 09:24:05.239  2586  2586 D TSLocationManager:   ✅  DESTROY: 3d528f33-6a09-4cbb-9bba-ab5ab6558b27
05-06 09:24:05.263  2586  2586 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first]
05-06 09:24:05.263  2586  2586 D TSLocationManager:   ✅  Locked 1 records
05-06 09:24:05.270  2586  2586 I TSLocationManager: [c.t.l.http.HttpService createRequest]
05-06 09:24:05.270  2586  2586 I TSLocationManager:   🔵  POST: 6a9d70cc-3ade-42f5-a247-efd608b07ca5
05-06 09:24:05.314  2586  2728 I TSLocationManager: [c.t.l.http.HttpRequest parseNetworkResponse]
05-06 09:24:05.314  2586  2728 I TSLocationManager:   🔵  Response: 200
05-06 09:24:05.326  2586  2728 D TSLocationManager: [c.t.l.http.HttpRequest parseNetworkResponse]
05-06 09:24:05.326  2586  2728 D TSLocationManager:   ℹ️  No JSON found in server response
05-06 09:24:05.337  2586  2586 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO destroy]
05-06 09:24:05.337  2586  2586 D TSLocationManager:   ✅  DESTROY: 6a9d70cc-3ade-42f5-a247-efd608b07ca5
05-06 09:24:05.357  2586  2586 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first]
05-06 09:24:05.357  2586  2586 D TSLocationManager:   ✅  Locked 1 records
05-06 09:24:05.365  2586  2586 I TSLocationManager: [c.t.l.http.HttpService createRequest]
05-06 09:24:05.365  2586  2586 I TSLocationManager:   🔵  POST: d18fa8c3-9a5a-46be-9557-8dae6da3f63a
05-06 09:24:05.536  2586  2586 D TSLocationManager: [c.t.l.http.HttpService onRequestError]
05-06 09:24:05.536  2586  2586 D TSLocationManager:   ⚠️  HTTP Response: 403; <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
05-06 09:24:05.536  2586  2586 D TSLocationManager: <html><head>
05-06 09:24:05.536  2586  2586 D TSLocationManager: <title>403 Forbidden</title>
05-06 09:24:05.536  2586  2586 D TSLocationManager: </head><body>
05-06 09:24:05.536  2586  2586 D TSLocationManager: <h1>Forbidden</h1>
05-06 09:24:05.536  2586  2586 D TSLocationManager: <p>You don't have permission to access /post.php
05-06 09:24:05.536  2586  2586 D TSLocationManager: on this server.<br />
05-06 09:24:05.536  2586  2586 D TSLocationManager: </p>
05-06 09:24:05.536  2586  2586 D TSLocationManager: <hr>
05-06 09:24:05.536  2586  2586 D TSLocationManager: <address>Apache/2.4.18 (Ubuntu) Server at posttestserver.com Port 80</address>
05-06 09:24:05.536  2586  2586 D TSLocationManager: </body></html>
ghost commented 7 years ago

Yes, this is MIUI issue. It applies additional security and battery saving measures, while vanilla android does not. I upgraded from MIUI 7 to 8 and now even bg location service works only once, after app start. After that - silence.

ghost commented 7 years ago

Here is what one need to do to make it work.

MIUI 7 and 8

  1. Settings -> Battery & Performance -> Manage apps battery usage : Off
  2. Settings -> Additional Settings -> Developer Options -> Memory Optimization: Off
  3. Settings -> Additional Settings -> Developer Options -> MIUI Optimization: Off

This will prevent killing background processes.

  1. Settings -> Privacy -> Location -> Mode : switch to Device Only, then back to High Accuracy

This will keep GPS active during app life cycle, otherwise it will switch off... Yes, buggy shit.

That's great, solves the problem for development stage, but the bad thing is Xiaomi is pretty popular low coster. Users will likely face the same issues using application.

christocracy commented 7 years ago

I'm curious: With default OS settings, what happens when you start a music player (eg: Play Music) playing a song then terminate the player?

The music should keep playing. It's the same for location-tracking.

jayeshanandani commented 6 years ago

@tephro : were you able to get solution for this? As this still happens in vivo, xiaomi and other flavors.