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

Push Events Not Completing Successfully #291

Open
rgb99 opened this issue Sep 5, 2018 · 28 comments
Open

Push Events Not Completing Successfully #291

rgb99 opened this issue Sep 5, 2018 · 28 comments

Comments

@rgb99
Copy link

rgb99 commented Sep 5, 2018

Push events are not completing without errors.

screenshot_20180905-162504

Entry from log shows 'Error: No Internet Connection'

ANDROID DEVICE: Pixel 2 XL
BUILD: PPR2.180905.005
ANDROID VERSION: 9
APP VERSION: 4.4.5
TIMEZONE: libcore.util.ZoneInfo[id="America/New_York",mRawOffset=-18000000,mEarliestRawOffset=-18000000,mUseDst=true,mDstSavings=3600000,transitions=235]LP: Free
Starting Sync...
[2018-09-05 16:21:29] Exchange Server Version: Exchange2016
[2018-09-05 16:21:29] entering SyncEventsTask doInBackground...
[2018-09-05 16:21:29] entering SyncEventsTask onPostExecute...
[2018-09-05 16:21:29] Error: No Internet Connection

A manual Sync works just fine.

@blueleader07
Copy link
Contributor

Thanks for reporting the issue. It looks to me like you are able to sync when the app is open ... but not when the app is running in the background. Most likely the app is not able to access data while running in the background. Check that you have background data enabled for the app. See the wiki post here:
https://github.com/TeamsiteDesign/TeamCalendarSync-Public/wiki/Background-Sync-Errors

Let me know if this does not resolve the issue.

@rgb99
Copy link
Author

rgb99 commented Sep 8, 2018 via email

@k1sr
Copy link

k1sr commented Oct 29, 2018

My application is not performing push sync at all.

It sits dormant for days, and has done nothing despite new events being added to my Exchange calendar.

THe app is enable in the background, and I have battery optimisation turned off.

@saabdeep
Copy link

Same issue over here unfortunately. Running Marsh 6.0 on HTC 10

@blueleader07
Copy link
Contributor

Thanks for reporting this issue.

A couple other users have sent me emails about this over the past few weeks. It seems like "Push" works for a while and then stops working. As far as I know, this is not impacting everyone. My guess is that the Exchange server gets rebooted (perhaps after routine maintenance) and when it restarts it needs to be "reminded" about all the clients waiting for push notifications. In the past I addressed this issue by designing the app so that it would "restart Push" automatically if it stopped. I don't think this feature is working anymore -- seems like Push is stopping and not restarting automatically.

As a short term workaround you can try the following:

  1. Open Team Calendar Sync
  2. Navigate to the "Edit Calendar" screen
  3. Change the "Sync Frequency" to "Manual"
  4. Save.
  5. Navigate back to the "Edit Calendar" screen
  6. Change the "Sync Frequency" to "Push"
  7. Save. You'll briefly see a "Setting up push..." popup.

This is a manual way of "restarting" Push notifications. This should get Push going again for you ... but it could crop up again if your Exchange server is rebooted. It will probably work for a couple months and then stop (just a guess).

In the meantime I will work on a long term solution.

@saabdeep
Copy link

saabdeep commented Dec 14, 2018

Any progress on this Sean? I'm a Software Engineer, and if your schedule is like mine there's been a big push to get things out before the holiday so I can understand not having much time to work on side projects. Sadly, your trick above doesn't work for me, and neither does dropping the account entirely and adding; only manually starting sync updates my calendar. I think you're the only solution in town for this unfortunately. Anyway, good luck!

@blueleader07
Copy link
Contributor

Hi Saabdeep,
Thanks for your patience and for following up. I've had a new version that I've been testing for the past 2 - 3 weeks. I upgraded my push notifications from some PHP scripts I wrote a few years back to Firebase push notifications. I'm hoping that the FIrebase version works better that my own PHP server. Please give it a try.

The new version is 4.5. After installing the update please open Team Calendar Sync. Opening the app triggers the automatically switch from PHP -> Firebase notifications.

You can testing push notifications by creating / updating / or deleting an event on your Outlook calendar. You should see a sync run a few seconds after making a change to your Outlook calendar. If you aren't seeing push notifications for some reason ... you might need to do the following steps to setup Firebase push notifications.:

  1. Open Team Calendar Sync
  2. Navigate to the "Edit Calendar" screen
  3. Change the "Sync Frequency" to "Manual"
  4. Save.
  5. Navigate back to the "Edit Calendar" screen
  6. Change the "Sync Frequency" to "Push"
  7. Save. You'll briefly see a "Setting up push..." popup.

Hopefully you don't have to do the extra setup steps ... but I've only tried it on my own device so far and it worked. So this rollout will be the big test!

Please let me know if you have any issues.

@saabdeep
Copy link

Just tested. It works!!! Many thanks for this! My director likes to schedule last-minute meetings over the lunch hour for directly after lunch :-/ so keeping the calendar up-to-date is a necessity!

Cheers and happy holidays,

J.

@saabdeep
Copy link

So I have an update:

While events do seem to be updating fairly quickly, I'm not so sure that this is a result of actual push sync, but rather a very frequent polling that is happening in duplicate, and every 3-4 minutes. Unfortunately the result is that Team Cal Sync is using quite a bit of battery due to this: I've attached some screenshots of the sync behaviour which is continuous, and a screenshot of the battery usage I'm experiencing.

Perhaps some weirdness with Firebase and certain versions of Android? I'm curious as to the other members of this thread...

Cheers,

J.

image

image

image

image

@blueleader07
Copy link
Contributor

Thanks for the info Saabdeep. Are you syncing more than 1 calendar by any chance?

My device does not seem to be syncing as much as yours -- but I'm going to keep watching it. Also interested to hear if others are experiencing the same issue.

@saabdeep
Copy link

Only the one outlook 365 calendar, which is my main work calendar. Weird issue.

@saabdeep
Copy link

saabdeep commented Jan 4, 2019

Push is definitely not working correctly. I'ts polling less than before, but there doesn't seem to be any rhyme or reason with respect to time or to changes to the calendar, as illustrated below. The most recent sync at the top I had to manually kick off. Any ideas whether this is an issue with Team Calendar sync, Firebase settings, or the marriage of the two? As it stands I have to open up the OWA to reliably check to see if I have any meetings, or manually sync every 15 minutes, which defeats the whole purpose of push :-/

image

@blueleader07
Copy link
Contributor

Hi Saabdeep. Thanks for the continued info. I'll spend some time this weekend testing to see if I can find a pattern. I haven't had any trouble -- but I don't think I have as many events as you. Sounds like your calendar is updated pretty frequently (hence the need for very reliable push). I'll need to hit my app hard and see how it responds. Will post an update by Monday at the latest.

@saabdeep
Copy link

saabdeep commented Jan 5, 2019

Thanks Sean. Before this issue was originally reported, push worked flawlessly, only when a change was detected. Currently it seems to be polling in ~30 minute intervals. I don't have that many events, it's just that my director likes to constantly change meeting times last-minute or throw stuff on our calendar the day of (sometimes with < 1 hour notice, during lunch) so yeah, I relied pretty heavily on the push.

Should I consider installing a previous build from a few months back? Are any of those builds backwards compatible with respect to Firebase?

Cheers,

J.

@blueleader07
Copy link
Contributor

The old (pre firebase) push service is still running. I'd like to shut it down though once I know for sure the Firebase version is working properly.

The problems started when Google announced that all developers had to updated their apps to be compatible with at least Android 26. My app was working great (as you said), but it was targeting Android 23. Once I updated to a newer version of Android ... I found that Google had deprecated all their old push notifications in favor of Firebase. They also changed the way background services worked. So I had to make a number of changes to align myself with Google requirements.

https://developer.android.com/distribute/best-practices/develop/target-sdk
Google Play will require that new apps target at least Android 8.0 (API level 26) from August 1, 2018, and that app updates target Android 8.0 from November 1, 2018.

So it's been a bit of a rabbit hole. Usually I encounter "breaking changes" with Apple ... not Google. So hopefully once this is settled things will be stable again for quite some time.

@saabdeep
Copy link

saabdeep commented Jan 5, 2019

Ahh, makes sense now. Thanks for the info. It wouldn't be that much of a hassle, except for the polling is using between 5%-9% of my battery as a background app. It's usually second in the list after whatever foreground app I've been on recently. In the meantime, I'm using Tasker to run a shell command to disable the Team Calendar app package outside of working hours and re-enable during. It seems to work OK as an interim solution. Best of luck on sorting it properly!

@blueleader07
Copy link
Contributor

Hi Saabdeep,

I might have found the issue. Root cause: bugs in my new push server code ... ugh.

First, the push server was not handling bad push configs properly. This might impact existing users (new users avoid the issue). If you are like me you change between "Manual" and "Push" quite a bit for testing purposes. Well... those "old" push configs are supposed to get cleared out from my push server. It seems this was not always happening. So when you were trying to use push my push server was blowing up on the old configs and not always sending you messages (was happening to me ... probably you too).

The second bug I found was the push server was sending notifications at random (sort of). If another user had a similar device ID (Android device ids are generated randomly) then an update to their calendar could have triggered a push notification to your device. This probably explains the craziness you were seeing with lots of random pushes. I had some bad comparison logic that was to blame. So, for example, if your device id was 5 and another user was 2 my (bad) logic was sending push notifications to users with device id greater than or equal to 2 ... lots of notifications being sent unintentionally. The side effect was ... users calendars were more or less up to date due to all the notifications haha ... but ... not the right behavior... and also probably battery drain. I've corrected this so that the notifications are now targeting the correct users. Logic is if device id EQUALS (not greater than equal ... not sure how I fat-fingered that one).

Please do the following when you have a chance:

  1. Change your sync frequency to "Manual"
  2. Save
  3. Change your sync frequency to "Push"
  4. Save
  5. Test changing some events. You should see syncs running shortly after modifications are made (within a minute or so).

Fingers crossed!

@blueleader07
Copy link
Contributor

Just to make it clear on my previous comment:
No data was shared between users or anything like that... I don't store any user data on my side (it all lives encrypted on your device). It was just the logic that sends a message "Hey something has changed you need to sync!" to your device that was going haywire.

@saabdeep
Copy link

saabdeep commented Jan 6, 2019

Sean,

I toggled from push to manual and back to push a few hours ago and let it run. Still syncing a lot in the background. So, all the changes were to server code for Firebase so no update to the app itself is needed? Just making sure.

screenshot_20190106-115746

@blueleader07
Copy link
Contributor

Yes -- no app update needed. The code bugs were found and fixed in the push server code.

I just deployed a new version (4.5.1), but the only thing I added was some additional logging to help debug some crashes I've seen. No logic or functionality changes.

I wonder ... maybe you had scheduled syncs running (like every 15 minutes) ... and those are still running somehow even though you switched to push? Rebooting your Android device might clear those out. Worth a try. Perhaps I'm not "cleaning up" scheduled syncs properly when you switch to push or manual.

@saabdeep
Copy link

saabdeep commented Jan 6, 2019

Indeed you could be onto something, because I switched to manual sync over 30 mins ago, and it's synced almost 10 times since! I will reboot and report back..

@saabdeep
Copy link

saabdeep commented Jan 6, 2019

So! I removed the account completely, rebooted, and re-added from scratch. So far so good! Only one initial sync when it set up the push. I need to add an event from an external source to see if it updates correctly,but this is promising!

@saabdeep
Copy link

saabdeep commented Jan 7, 2019

Update: so, no syncs for several hours, which was good. Then just before 18:00, 8 events changed (not triggered by me) and it synced. That must have triggered something because after that it's syncing every 10 minutes or so again. This issue is so strange.

screenshot_20190106-190325

@blueleader07
Copy link
Contributor

Hi Saabdeep,

I'll see if I can add some more info to that history screen. It would be nice to know "what" triggered each sync. Perhaps I will add a third line to each item in the Sync History ... so it will look something like:

COMPLETE
Started: 01/06/2019 06:10PM 0 events
Trigger: Push Notification

vs.

COMPLETE
Started: 01/06/2019 06:10PM 0 events
Trigger: Scheduled Sync

vs.

COMPLETE
Started: 01/06/2019 06:10PM 0 events
Trigger: Android Calendar Modified

That might help us determine what is causing all this noise. I'll try and get something published tonight or tomorrow at the latest.

@saabdeep
Copy link

saabdeep commented Jan 7, 2019

That extra bit would definitely help for tracking down the issue. I've since tried deleting my account/dumping the app cache/force closing/re-adding the account/changing sync to manual/push/every x minutes and in every different configuration I can come think of, with the same result. Push definitely doesn't work i.e. events are not updated until the random yet frequent polling starts up again. Maybe the extra info would tell us more about why the syncs were occurring so frequently, but even more perplexing is why a sync isn't triggered shortly after the calendar is modified when push is actually specified. I feel like I'm spamming you Sean, but really I'm just trying to offer as much info as possible. Cheers for your time and effort!

image

@saabdeep
Copy link

saabdeep commented Jan 9, 2019

Hi Sean - I have the latest 4.5.1 update, but I don't see any extra logging in the history with respect to what triggered the sync. Just FYI. Also, I've included some screenshots with notes that will hopefully assist. They are in reverse chronological order. Around 11 a.m. this morning, I completely uninstalled Team Cal Sync, rebooted, and re-added my Outlook 365 account to start from a fresh slate. Here's the results so far:

ss5
ss4
ss3
ss2
ss1

@blueleader07
Copy link
Contributor

Hi Saabdeep,

Thanks for the info. Version 4.5.2 will have the trigger info for you. I've just published it (5 min ago as I'm writing this). Sorry it took me an extra day to get it out. Hopefully 4.5.2 will help identify what is causing all the syncs.

@saabdeep
Copy link

Sean,

Me again 😝

I’ve been super-slammed at work until recently, so I’m chasing this again. It’s become an issue because TCS uses anywhere from 6%-19% of my battery with all this pinging. The interim solution I’m attempting is this:

Use Tasker and Greenify (rooted, Xposed version) to set up a schedule so that the Team Calendar Sync service only runs during business hours at 15-minute intervals. This would save me a lot of battery. The issue is that I can hibernate the service, but the ‘wake up’ command doesn’t seem to respond reliably. What I’m trying as a proposed solution is to run a shell command, but I don’t know which service(s) to hibernate/wake up. Here’s the command(s):

am startservice com.teamsite.android.calendar.generated/.service.CalendarSyncService
am startservice com.teamsite.android.calendar.generated/.service.AuthenticationService
am startservice com.teamsite.android.calendar.generated/.service.CalendarSyncAdapterService
am startservice com.teamsite.android.calendar.generated/.service.BackgroundSyncService
am startservice com.teamsite.android.calendar.generated/.jobs.CalendarChangeJob

a. I can hibernate the entire app without issue, but would it be sufficient to only wake up the first CalendarSyncService listed here, or would I need to wake up others listed above?
b. I realize the package name is com.teamsite.android.calendar.generated – but I’m not sure about including 'generated' bit in the service path call? Any input there?

Many thanks,

Jason Womack

P.S. I see the teamcalendarsync.com site domain and the associated mailbox over there bounces back, so that's why I posted here. Hope all is ok.

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

4 participants