transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.55k stars 426 forks source link

First Day your plugin sending the location perfectly to my server, second day sending the location for just 30 mins #1820

Closed zahoormohammed closed 2 weeks ago

zahoormohammed commented 8 months ago

Your Environment

React.useEffect(() => {
/// 1. Subscribe to events.
const onLocation:Subscription = BackgroundGeolocation.onLocation((location) => {
console.log('[onLocation]', location);
setLocation(JSON.stringify(location, null, 2));
})

const onMotionChange:Subscription = BackgroundGeolocation.onMotionChange((event) => {
  console.log('[onMotionChange]', event);
});

const onActivityChange:Subscription = BackgroundGeolocation.onActivityChange((event) => {
  console.log('[onActivityChange]', event);
})

const onProviderChange:Subscription = BackgroundGeolocation.onProviderChange((event) => {
  console.log('[onProviderChange]', event);
})

/// 2. ready the plugin.
BackgroundGeolocation.ready({
  // Geolocation Config
  desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
  distanceFilter: 10,
  // Activity Recognition
  stopTimeout: 5,
  // Application config
  debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
  logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
  enableHeadless: true,
  stopOnTerminate: false,   // <-- Allow the background-service to continue tracking when user closes the app.
  startOnBoot: true,        // <-- Auto start tracking when device is powered-up.
  // HTTP / SQLite config
  url: myValue,
  batchSync: false,       // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
  autoSync: true,         // <-- [Default: true] Set true to sync each location to server as it arrives.
  headers: {              // <-- Optional HTTP headers
    "X-FOO": "bar"
  },
  params: {               // <-- Optional HTTP params
    "auth_token": "maybe_your_server_authenticates_via_token_YES?"
  }
}).then((state) => {
    // console.log("It is started again successfully-------------------")
    console.log("state of location tracking is");
    console.log(state.enabled);
  setEnabled(state.enabled)
  console.log("- BackgroundGeolocation is configured and ready: ", state.enabled);
});

return () => {
  // Remove BackgroundGeolocation event-subscribers when the View is removed or refreshed
  // during development live-reload.  Without this, event-listeners will accumulate with
  // each refresh during live-reload.

  console.log("stopped event listeners successfully");
  onLocation.remove();
  onMotionChange.remove();
  onActivityChange.remove();
  onProviderChange.remove();
}
}, []);

/// 3. start / stop BackgroundGeolocation
React.useEffect(() => {

if (enabled) {
  BackgroundGeolocation.start();
} else {
  BackgroundGeolocation.stop();
  setLocation('');
}
}, [enabled]);

Expected Behavior

Should send location to my server after 30 mins on second day, first day it is working fine.

Actual Behavior

Not sending location to my server on second day after 30mins, stopping in between and not working at all even after multiple attempt to enable and disable tracking

Steps to Reproduce

1. 2. 3. 4.

Context

we just purchased this license for react native last 1 month back, in my app i am implemented your plugin, first day when i install the app in my phone and enable the location tracking it is perfectly sending all locations to my server, at night i have turned off tracking. Then next day morning i have enabled the location tracking it started perfectly and started sending the locations, but after 30 mins it has stopped sending location to my server, this issue happened 3 times with me. my mobile is giving the beep sound that location tracking is working fine, but it seems like there is something wrong at your sql backend which transmit data to my server, may i please know is there any limitations of sending location to our server? when the location tracking is stopping after 30 mins, even after enabling and disabling location tracking multiple times it is not sending location of my server at all. i am even using headless in my project this is my code

Debug logs

Logs ``` PASTE_YOUR_LOGS_HERE ```
christocracy commented 8 months ago

See Wiki Debugging and learn how to fetch the plugin's logs from its database using the .emailLog(address) method.

The plugin's logging system is incredibly verbose. Also see API docs Logger

No, there are no "limitations".

zahoormohammed commented 8 months ago

09-15 10:50:11.704 29700 29700 I TSLocationManager: ║ Location-provider change: true 09-15 10:50:11.704 29700 29700 I TSLocationManager: ╠═════════════════════════════════════════════ 09-15 10:50:11.704 29700 29700 I TSLocationManager: ╟─ GPS: true 09-15 10:50:11.704 29700 29700 I TSLocationManager: ╟─ Network: false 09-15 10:50:11.704 29700 29700 I TSLocationManager: ╟─ AP Mode: false 09-15 10:50:11.758 29700 29700 W TSLocationManager: [c.t.l.service.AbstractService startForegroundService] 09-15 10:50:11.758 29700 29700 W TSLocationManager: ℹ️ Background FGS launch denied: Retrying with AlarmManager...Intent { act=start cmp=com.hrete_0_71_4/com.transistorsoft.locationmanager.service.LocationRequestService (has extras) } 09-15 10:50:11.762 29700 29700 I TSLocationManager: [c.t.l.s.TSScheduleManager oneShot] 09-15 10:50:11.762 29700 29700 I TSLocationManager: ⏰ Scheduled OneShot: LAUNCH_FOREGROUND_SERVICE in 0ms (jobID: -1823535195) 09-15 10:50:12.006 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService start] 09-15 10:50:12.006 29700 29700 D TSLocationManager: 🎾 GeofencingService [eventCount: 1] 09-15 10:50:12.017 29700 20565 D TSLocationManager: [c.t.l.adapter.TSConfig d] ℹ️ Persist config, dirty: [isMoving] 09-15 10:50:12.024 29700 20565 I TSLocationManager: [c.t.l.service.HeartbeatService stop] 09-15 10:50:12.024 29700 20565 I TSLocationManager: 🔴 Stop heartbeat 09-15 10:50:12.031 29700 20565 D TSLocationManager: [c.t.l.g.TSGeofenceManager stopMonitoringStationaryRegion] 09-15 10:50:12.031 29700 20565 D TSLocationManager: 🔴 Stop monitoring stationary region 09-15 10:50:12.043 29700 20565 D TSLocationManager: [c.t.locationmanager.util.c h] 09-15 10:50:12.043 29700 20565 D TSLocationManager: ℹ️ LocationAuthorization: Permission granted 09-15 10:50:12.044 29700 20565 I TSLocationManager: [c.t.l.service.TrackingService changePace] 09-15 10:50:12.044 29700 20565 I TSLocationManager: 🔵 setPace: false → true 09-15 10:50:12.072 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService start] 09-15 10:50:12.072 29700 29700 D TSLocationManager: 🎾 TrackingService [eventCount: 1] 09-15 10:50:12.073 29700 29700 I TSLocationManager: [c.t.l.service.TrackingService handleMotionChangeResult]


09-15 10:50:14.641 29700 29700 I TSLocationManager: ║ Location-provider change: true 09-15 10:50:14.641 29700 29700 I TSLocationManager: ╠═════════════════════════════════════════════ 09-15 10:50:14.641 29700 29700 I TSLocationManager: ╟─ GPS: true 09-15 10:50:14.641 29700 29700 I TSLocationManager: ╟─ Network: true 09-15 10:50:14.641 29700 29700 I TSLocationManager: ╟─ AP Mode: false 09-15 10:50:14.660 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService finish] ⚙️︎ finish LocationRequestService [eventCount: 0, sticky: false] 09-15 10:50:14.674 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService onDestroy] 09-15 10:50:14.674 29700 29700 D TSLocationManager: 🔴 LocationRequestService stopped 09-15 10:50:14.716 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService start] 09-15 10:50:14.716 29700 29700 D TSLocationManager: 🎾 LocationRequestService [eventCount: 1] 09-15 10:50:14.717 29700 21886 I TSLocationManager: [c.t.l.l.SingleLocationRequest startUpdatingLocation] 09-15 10:50:14.717 29700 21886 I TSLocationManager: 🔵 [SingleLocationRequest start, action: 3, requestId: 9] 09-15 10:50:14.720 29700 21886 D TSLocationManager: [c.t.l.service.AbstractService finish] ⚙️︎ finish LocationRequestService [eventCount: 0, sticky: true] 09-15 10:50:14.784 29700 21907 W TSLocationManager: [c.t.l.http.HttpService$h onResponse] 09-15 10:50:14.784 29700 21907 W TSLocationManager: ⚠️ Response: 500, 09-15 10:50:14.797 29700 21907 D TSLocationManager: [c.t.l.data.sqlite.b unlock] 09-15 10:50:14.797 29700 21907 D TSLocationManager: ✅ UNLOCKED: 46267aac-0e24-4267-96ee-cf5a94418cb7 09-15 10:50:14.797 29700 21907 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 424 09-15 10:50:14.798 29700 21907 D TSLocationManager: [c.t.l.service.AbstractService finish] ⚙️︎ finish BackgroundTaskService [eventCount: 0, sticky: false] 09-15 10:50:14.801 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService onDestroy] 09-15 10:50:14.801 29700 29700 D TSLocationManager: 🔴 BackgroundTaskService stopped 09-15 10:50:15.710 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService start] 09-15 10:50:15.710 29700 29700 D TSLocationManager: 🎾 TrackingService [eventCount: 1] 09-15 10:50:15.712 29700 29700 D TSLocationManager: [c.t.l.service.TrackingService handleLocationResult]


09-15 10:50:15.712 29700 29700 D TSLocationManager: ║ TrackingService: LocationResult 09-15 10:50:15.712 29700 29700 D TSLocationManager: ╠═════════════════════════════════════════════ 09-15 10:50:15.712 29700 29700 D TSLocationManager: ╟─ 📍 Location[gps *** hAcc=13.0 et=+16h19m39s952ms alt=129.25581587 vAcc=0.1 vel=14.063463 sAcc=0.01 bear=268.5683 bAcc=0.1 mock] 09-15 10:50:15.712 29700 29700 D TSLocationManager: ╟─ Age: 93ms, time: 1694755215617 09-15 10:50:15.713 29700 21886 D TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult] 09-15 10:50:15.713 29700 21886 D TSLocationManager: ╔═════════════════════════════════════════════ 09-15 10:50:15.713 29700 21886 D TSLocationManager: ║ Process LocationResult 09-15 10:50:15.713 29700 21886 D TSLocationManager: ╠═════════════════════════════════════════════ 09-15 10:50:15.714 29700 21886 D TSLocationManager: [c.t.l.l.TSLocationManager locationIsInvalid] Distance from last location: 42.249985, apparent speed: 13.962322 09-15 10:50:15.714 29700 21886 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] Median accuracy: 9.814 09-15 10:50:15.715 29700 21886 D TSLocationManager: [c.t.l.l.TSLocationManager incrementOdometer] Odometer: 34132.746 09-15 10:50:15.718 29700 29700 D TSLocationManager: [c.t.l.service.TrackingService beginStopTimer] 🐞 Mock location detected with motion-activity STILL: stopTimeout timer would normally be initiated here 🐞. 09-15 10:50:15.723 29700 29700 W TSLocationManager: [c.t.l.service.TrackingService performStopDetection] 09-15 10:50:15.723 29700 29700 W TSLocationManager: ⚠️ performStopDetection found mStoppedAtLocation == null 09-15 10:50:15.724 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService finish] ⚙️︎ finish TrackingService [eventCount: 0, sticky: true] 09-15 10:50:15.745 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService start] 09-15 10:50:15.745 29700 29700 D TSLocationManager: 🎾 LocationRequestService [eventCount: 1] 09-15 10:50:15.747 29700 21856 I TSLocationManager: [c.t.l.s.LocationRequestService handleLocationResult]


providerchange LocationResult: 9 09-15 10:50:15.747 29700 21856 I TSLocationManager: ╠═════════════════════════════════════════════ 09-15 10:50:15.747 29700 21856 I TSLocationManager: ╟─ 📍 Location[gps *** hAcc=13.0 et=+16h19m39s952ms alt=129.25581587 vAcc=0.1 vel=14.063463 sAcc=0.01 bear=268.5683 bAcc=0.1 mock], age: 128ms, time: 1694755215617 09-15 10:50:15.825 29700 20565 I TSLocationManager: [c.t.l.data.sqlite.b persist] 09-15 10:50:15.825 29700 20565 I TSLocationManager: ✅ INSERT: b6bdc5b5-bbfd-445e-855c-6ecfe8887d5c 09-15 10:50:15.836 29700 20565 I TSLocationManager: [c.t.l.http.HttpService flush] 09-15 10:50:15.836 29700 20565 I TSLocationManager: ╔═════════════════════════════════════════════ 09-15 10:50:15.836 29700 20565 I TSLocationManager: ║ HTTP Service (count: 301) 09-15 10:50:15.836 29700 20565 I TSLocationManager: ╠═════════════════════════════════════════════ 09-15 10:50:15.838 29700 21856 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult] 09-15 10:50:15.838 29700 21856 I TSLocationManager: 🔵 Acquired providerchange position 09-15 10:50:15.839 29700 21856 D TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] Median accuracy: 10.094 09-15 10:50:15.846 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService finish] ⚙️︎ finish LocationRequestService [eventCount: 0, sticky: false] 09-15 10:50:15.849 29700 21856 D TSLocationManager: [c.t.l.s.LocationRequestService handleLocationResult] SingleLocationRequest 9 isFinished? true 09-15 10:50:15.850 29700 21856 D TSLocationManager: [c.t.l.service.AbstractService finish] ⚙️︎ finish LocationRequestService [eventCount: 0, sticky: false] 09-15 10:50:15.852 29700 20565 I TSLocationManager: [c.t.l.data.sqlite.b persist] 09-15 10:50:15.852 29700 20565 I TSLocationManager: ✅ INSERT: 6210c90f-8815-44c5-aad2-a8ec7cd5674f 09-15 10:50:15.856 29700 20565 I TSLocationManager: [c.t.l.http.HttpService flush] 09-15 10:50:15.856 29700 20565 I TSLocationManager: ℹ️ HttpService is busy 09-15 10:50:15.877 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService start] 09-15 10:50:15.877 29700 29700 D TSLocationManager: 🎾 BackgroundTaskService [eventCount: 1] 09-15 10:50:15.878 29700 29700 I TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task start] ⏳ startBackgroundTask: 425 09-15 10:50:15.880 29700 29700 D TSLocationManager: [c.t.l.service.AbstractService onDestroy] 09-15 10:50:15.880 29700 29700 D TSLocationManager: 🔴 LocationRequestService stopped 09-15 10:50:15.881 29700 29700 D TSLocationManager: [c.t.l.l.TSLocationManager$b onLocation] 09-15 10:50:15.881 29700 29700 D TSLocationManager: ℹ️ Distance from last location: 62.249985 09-15 10:50:15.885 29700 20565 D TSLocationManager: [c.t.l.data.sqlite.b first] 09-15 10:50:15.885 29700 20565 D TSLocationManager: ✅ Locked 1 records 09-15 10:50:15.885 29700 20565 I TSLocationManager: [c.t.l.http.HttpService a] 09-15 10:50:15.885 29700 20565 I TSLocationManager: 🔵 HTTP POST: 46267aac-0e24-4267-96ee-cf5a94418cb7 09-15 10:50:16.805 29700 20565 I TSLocationManager: [c.t.l.scheduler.ScheduleEvent onOneShot]


After testing outside while driving today, again it has stopped sending location to my server after 15mins, now after reaching the office i started mock location , now still it is not saving any location on my server. from log messages it seems like it is saving in your sqllite, but not sending that data to my server

christocracy commented 8 months ago

It’s pretty clear to me that your server is returning 500 errors. Are you not checking your server logs??

TSLocationManager: ⚠️ Response: 500,

zahoormohammed commented 8 months ago

we are not using any dedicated server to save locations, we are using java microservices api's to save location. our db is in google cloud. does it require any server to store locations?

zahoormohammed commented 8 months ago

After 15mins it has stopped storing the location. then when we hit the same api using postman the api is working fine and stored the location, later again when we start location tracking it is working as expected and saving all locations, and it is saving location perfectly when i uninstall the existing one and install the new app.

christocracy commented 8 months ago

From you config:

url: myValue,

the plug-in is sending http requests to your “myUrl”.. Regardless of what sits behind your “myUrl”, that url is returning “500”.

Masniper commented 5 months ago

i cant run background-geolocation after configure and start i get this:

2024-01-01 16:54:23.270 1063-1063 TSLocationManager com.App.Name [c.t.l.service.AbstractService onDestroy] 🔴 LocationRequestService stopped

christocracy commented 5 months ago

That is a normal and expected log message. The plug-in tracks location when the device is detected to be moving.

Read the wiki "Philosophy of Operation" and go outside for a test, moving >= 1km.

github-actions[bot] commented 4 weeks ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been inactive for 14 days since being marked as stale.