Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate locations recieved in backend #1401

Open
prithivirajQS opened this issue Jan 5, 2025 · 9 comments
Open

Duplicate locations recieved in backend #1401

prithivirajQS opened this issue Jan 5, 2025 · 9 comments

Comments

@prithivirajQS
Copy link

Your Environment

  • Plugin version: 4.16.2
  • Platform: Android
  • OS version: 12
  • Device manufacturer / model: Samsung
  • Flutter info (flutter doctor):
  • Plugin config:
bg.Config(
            reset: false,
            debug: false,
            logLevel: bg.Config.LOG_LEVEL_OFF,
            desiredAccuracy: bg.Config.DESIRED_ACCURACY_MEDIUM,
            method: "POST",
            autoSync: true,
            autoSyncThreshold: 1,
            stopOnTerminate: false,
            startOnBoot: true,
            batchSync: true,
            stopOnStationary: false,
            url: url,
            locationUpdateInterval: timeinms,
            fastestLocationUpdateInterval: timeinms > 1000 ? timeinms - 1000 : timeinms,
            locationTemplate: paramsToServer,
            minimumActivityRecognitionConfidence: 25,
            foregroundService: true,
            notification: bg.Notification(
              priority: bg.Config.NOTIFICATION_PRIORITY_HIGH,
              sticky: true,
              text: "Location Service Activated - ${(postTemplate['u_flag'] ?? 'R').toString()}",
              title: AppConfigs.APP_NAME,
            ),
            backgroundPermissionRationale: bg.PermissionRationale(
              title: AppConfigs.BG_PERMISSION_TITLE,
              message: AppConfigs.BG_PERMISSION_MESSAGE,
              positiveAction: "OK",
              negativeAction: "Cancel",
            ),
            enableHeadless: true,
          ),

Expected Behavior

After sending the locations in batch/single, the location should not come to backend.

Actual Behavior

I am recieving duplicates with same timestamps. You can see that in the attached file.
Uploading po22 - Copy.txt…

Steps to Reproduce

Context

Driver application for cab to track route of the vehicle.

Debug logs

Logs
PASTE_YOUR_LOGS_HERE
@prithivirajQS
Copy link
Author

prithivirajQS commented Jan 5, 2025

Uploading po22 - Copy.txt…

Should my config be changed to prevent the above behaviour ?

@christocracy
Copy link
Member

See api docs Location.age

@prithivirajQS
Copy link
Author

prithivirajQS commented Jan 5, 2025

I have reviewed the documentation on Location.age but am still unclear about preventing duplicate locations with the same timestamps from being sent to the backend. Could you provide detailed guidance on adjusting configurations to resolve this issue?

@christocracy
Copy link
Member

It’s not strictly a duplicate location if location.uuid is different.

If you don’t like a particular location at your server, then filter it out and don’t save it.

it’s not unusual that the native location api provides the last known location under certain circumstances.

@MilesAdamson
Copy link

We have the same issue and the locations are sent with the exact same uuid. We know this because we save them under their uuid in our back end and they must be unique. We have many many many errors logged from attempting to save breadcrumbs and it fails since a breadcrumb of the same uuid was already saved.

#894

@christocracy
Copy link
Member

The plugin cannot create two records in its SQLite database having the same location.uuid.

If your server does not return an HTTP status 200 from the plugin's HTTP request to your Config.url, it will keep re-trying (until Config.maxDaysToPersist automatically removes it).

If you want the plugin delete its copy (and stop re-trying to POST to your server), return an HTTP status 200 (not an error code).

@MilesAdamson
Copy link

MilesAdamson commented Jan 10, 2025

We do return 200. In fact we changed the endpoint to return 200 immediately and do its work afterwards, so that no matter what happens or how long it takes, we return 200 ASAP to try to get the plugin to think it worked (even if it didn't, and we would lose data this way). We made this change because our server is so hammered with breadcrumbs that it's becoming problematic. And it did not make a noticeable change

@christocracy
Copy link
Member

We made this change because our server is so hammered with breadcrumb

and you're saying your server is being hammered because these "breadcrumbs" all have identical uuid?

I have tens of millions of records at my public demo server at https://tracker.transistorsoft.com and there are no identical uuid.

@MilesAdamson
Copy link

MilesAdamson commented Jan 10, 2025

Duplicate geolocation data is an issue effecting our server, yes. We get bursts of tens of millions of requests, sometimes a single user will send 150,000 requests in a single day.

We know from azure app insights that our server is always returning OK to these requests without error, and quickly, and that some of these locations logged have the exact same uuid from the same user.

There are also many locations recorded with the exact same lat/lng and timestamp but a different uuid. I understand this is the intended behavior of the plugin but for the purposes of seeing someone on a map at a location, it is not useful information as nothing would update. If a way was added to opt-out of sending those to the API (send something on change only) that would cut down traffic substantially as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants