ring icon indicating copy to clipboard operation
ring copied to clipboard

Push notifications stop after ~24 hours

Open dgreif opened this issue 3 years ago • 107 comments

In #1212, we confirmed that clearing existing devices and re-authenticating seems to fix Push Notifications. However, some users are finding that the notifications only work for ~24 hours before they need to do the process again. The native apps don't seem to have this issue, so they must be sending some update to keep notifications working long term. We should investigate this further and find a way to avoid the daily bug.

See https://github.com/dgreif/ring/issues/1212#issuecomment-1546755943 for more details.

dgreif avatar May 17 '23 15:05 dgreif

Correct, notifications worked for 1 or 2 days max then stopped also for my Ring Intercom

salemsayed avatar May 18 '23 07:05 salemsayed

We should investigate this further…

If someone was interested in conducting this investigation, what steps would they need to take? Setting up mitmproxy and watching app traffic for a day or so?

smockle avatar May 18 '23 20:05 smockle

Great question @smockle! The hard part with mitmproxy is that the Ring App uses certificate pinning, which makes any MITM setup not work by default. There are ways around this, but they require a rooted device and a few pieces of software to get everything working. It's not a route I recommend others try to go down 😅.

Honestly I think this issue might be one that we can debug without necessarily seeing the traffic from the App. Based on the assessment from @tsightler in the other issue, I have a suspicion that the subscribed values are getting set to false after some period of time (24-48 hrs), so theoretically we should be able to take a token and hardware id belonging to a session from a few days ago and see what those values are. It might be as simple as watching those values and re-subscribing if they go false.

Another suspicion is that users experiencing this issue might be on a setup where they are not getting a consistent hardware id. This would present in the form of many "devices" showing up in the Control Center during that first 24 hour period. @salemsayed I'm curious, after you cleared your devices and waited a day, did you have just a few devices in Control Center, or was the list very long again?

dgreif avatar May 18 '23 22:05 dgreif

It might be as simple as watching those values and re-subscribing if they go false.

Unfortunately, the code in ring-mqtt already does this, at least it attempts to by calling subscribeToDingEvents()/subscribeToMotionEvents() when it detects this by checking the value on every poll event (20 seconds). The thing is, subscribing to the events doesn't appear to fail, but the observed behavior in the logs is that, once these values start showing up as false, they will revert back to unsubscribed every few minutes even after calling the subscribe function.

@smockle If you do decide to go down the path of mitmproxy, below is a post from a ring-mqtt user that did just that when they wanted me to implement a function that we didn't know how the API worked. It might help if you decide to go down that route, it didn't seem too hard.

https://github.com/tsightler/ring-mqtt/discussions/528#discussioncomment-4715702

I actually want to set this up myself, but time just hasn't been available for me lately.

tsightler avatar May 19 '23 01:05 tsightler

Great question @smockle! The hard part with mitmproxy is that the Ring App uses certificate pinning, which makes any MITM setup not work by default. There are ways around this, but they require a rooted device and a few pieces of software to get everything @salemsayed I'm curious, after you cleared your devices and waited a day, did you have just a few devices in Control Center, or was the list very long again?

Great question @smockle! The hard part with mitmproxy is that the Ring App uses certificate pinning, which makes any MITM setup not work by default. There are ways around this, but they require a rooted device and a few pieces of software to get everything working. It's not a route I recommend others try to go down 😅.

Honestly I think this issue might be one that we can debug without necessarily seeing the traffic from the App. Based on the assessment from @tsightler in the other issue, I have a suspicion that the subscribed values are getting set to false after some period of time (24-48 hrs), so theoretically we should be able to take a token and hardware id belonging to a session from a few days ago and see what those values are. It might be as simple as watching those values and re-subscribing if they go false.

Another suspicion is that users experiencing this issue might be on a setup where they are not getting a consistent hardware id. This would present in the form of many "devices" showing up in the Control Center during that first 24 hour period. @salemsayed I'm curious, after you cleared your devices and waited a day, did you have just a few devices in Control Center, or was the list very long again?

Just two devices right now, an unnamed device and homebridge-ring device.

salemsayed avatar May 19 '23 03:05 salemsayed

Just two devices right now, an unnamed device and homebridge-ring device.

Same here. Have been deleting and re-authenticating the devices for days now. Each time it's just the two: unnamed and Homebridge ring.

tammotheus avatar May 19 '23 15:05 tammotheus

Hi,

I use the ring-client-api in an app for the Homey Smart Home Platform (https://homey.app/) and there are quite some users of the app that are reporting the same exact problems with the notifications. The strange thing is that not all users seem to be affected by the bug, the app has ~5000 users but only a few compared to that amount have reported it. For some the removal of the devices at Ring has been a solution for a couple of days now, for others it only lasted a day. In my app the api connection is registered using the hardware ID of the Homey device, this is obviously unique per Homey and does not change. This results in 2 registrations at Ring, one with the name Homey (hardcoded in my app) and one with the name ring-client-api. When the app is restarted and thus a new connection is made and notifications are registered again there are no new devices created at Ring. Restarting the app does not necessarily cause the notifications to stop working, for some it’s a problem for others it isn’t. There are also users who lost notification that did not restart the app during the period it worked.

That’s all information I can add for now, I’m currently on vacation and have currently no way to do any troubleshooting myself. When I get more relevant information from my users I will post it here.

Edit: For anyone interrested, this is the code that sets up the connection with the Ring api: https://github.com/daneedk/com.amazon.ring/blob/22b0d0596e1114a374b9ef57757d88ac971cbb0e/lib/Api.js#L97

daneedk avatar May 19 '23 18:05 daneedk

Thanks for the info @daneedk! That sounds in-line with the other experiences described so far.

I personally use the standard Ring App notifications so I wasn't sure if this was affecting me. Enabled notifications this morning and mine are working just fine, so I'm not able to repro/debug 😞.

It sounds like there is a lot of variance in who is experiencing this. For those having issues, what version of Node.js are you on? I'm on 18.16.0 without issues.

dgreif avatar May 20 '23 13:05 dgreif

@daneedk That sounds exactly the same as what I'm seeing from ring-mqtt users as well. I estimate at least 6000 users of ring-mqtt based on various analytics data (it's probably higher, but so far only a few sporadic reports. Almost all started around May 4th and it's the first time it ever impacted my setup. However, since resetting all authorized users, my setup works perfectly for two weeks now.

However, its clear that other users see this work only for about 24 hours. For whatever reason, I've noticed that a lot of people with the issue do not have a Ring subscription, but not everyone. Perhaps there's just a higher percentage of Ring users that don't have a subscription than I realized. I'm also not sure that anyone that has reported the issue to this point is a US resident, so I wonder if the problem is happening in other regions vs the US.

However, I think it would be really good if we could start collecting this basic information from users experiencing the 24 hour issue to see if there's anything common. My suggestions for questions:

  1. When did you notice the problem?
  2. Did you remove all device and re-authenticate, if so, did this work and for how long?
  3. What devices do you have?
  4. What region/country are you located in?
  5. Do you have a ring subscription?

However, I'm also open to other suggestions. Not being able to reproduce the issue makes it particularly difficult to find any solution. One thing, at least one user has reported that the native Home Assistant Ring integration has the same problem, but it still uses the old polling method vs push notifications (as far as I know anyway).

tsightler avatar May 20 '23 14:05 tsightler

This problem occurs on both the old and new Homey. The old Homey uses nodejs v12.22.11 and the new Homey, which is really new and it’s firmware is still in Release Candidate phase, uses v18.16.0.

The old Homey has not been available in the US so no US based users for that one, the new Homey will be available in the US, but I’m not sure if any are shipped yet (I’ll try to get that confirmed)

The first report about this particular problem was posted on the Homey Community forum on the 10th of may. My app has a dedicated support topic on that forum, I will ask users that are experiencing the problem to answer the questions above.

daneedk avatar May 20 '23 16:05 daneedk

  1. When did you notice the problem? First week of May
  2. Did you remove all device and re-authenticate, if so, did this work and for how long? Six times so far. Between 16 and 36 hours.
  3. What devices do you have? Ring Intercom, Ring Chime
  4. What region/country are you located in? Germany
  5. Do you have a ring subscription? No

tammotheus avatar May 20 '23 18:05 tammotheus

  1. When did you notice the problem? First week of May
  2. Did you remove all device and re-authenticate, if so, did this work and for how long? Yes. Between 16 and 24 hours with ding events
  3. What devices do you have? Ring Doorbells (2).
  4. What region/country are you located in? Europe/Spain
  5. Do you have a ring subscription? No

pepepere avatar May 20 '23 20:05 pepepere

  1. When did you notice the problem? First week of May
  2. Did you remove all device and re-authenticate, if so, did this work and for how long? Yes, worked for around 48 hours, maybe a coincidence but it stopped after I had to restart Homebridge
  3. What devices do you have? Ring intercom
  4. What region/country are you located in? Germany
  5. Do you have a ring subscription? No

CooperCGN avatar May 21 '23 02:05 CooperCGN

Thanks for the responses everyone!

However, its clear that other users see this work only for about 24 hours. For whatever reason, I've noticed that a lot of people with the issue do not have a Ring subscription, but not everyone. Perhaps there's just a higher percentage of Ring users that don't have a subscription than I realized. I'm also not sure that anyone that has reported the issue to this point is a US resident, so I wonder if the problem is happening in other regions vs the US.

@tsightler you may have nailed the problem in this paragraph. I think the symptoms we are seeing likely stem from new Data Residency laws, which require data to only be stored within the region of the user. In some of the new laws, there is an acceptable period for data to be stored in another region, but only temporarily (something on the scale of 24-48 hours). If Ring is storing the session and push notification data in the US, it would make sense that they would only be able to store that same info for 24-48 hours for users in Spain/Germany.

Assuming this theory is correct, I'm guessing the apps are now configured to recreate the user session and push notification registration at least once a day. We should be able to do something similar from ring-client-api, re-posting these on a periodic basis. I haven't had a chance to try it out yet, but I think this should be pretty simple to change. I'll post back here as soon as I have some progress. I have a pretty relaxed weekend so I might be able to get to it tomorrow 🤞

dgreif avatar May 21 '23 02:05 dgreif

Hi, I’m having the same problem here in Canada.

When did you notice the problem? A few weeks ago, can’t tell exactly.

Did you remove all device and re-authenticate, if so, did this work and for how long? yes, 1-2 days

What devices do you have? Doorbell pro and stickup cam

What region/country are you located in? Canada

Do you have a ring subscription? Yes

AAMM007 avatar May 21 '23 13:05 AAMM007

@dgreif I think the theory of changes regarding data residency may make sense. Around the same time reports started of notification issues there was also another issue reported with ring-mqtt that I was pretty sure was indirectly related to the infrastructure changes. The ring-mqtt code polls the device health API every 5 minutes to update various attribute data. Around the same time notifications started having issues some users also reported an issue where this data was generating an error in ring-mqtt due to null data.

Investigating this issue, it appeared to only impact EU users. Querying the API still returned a result, but the JSON response mostly contained null values, especially for personally identifiable data like wifi network name. After about 24-48 hours everyone that reported the problem indicated that the behavior returned to normal. I had thought that maybe Ring was making changes to keep personally identifiable data, like wifi names, in-region.

Assuming this theory is correct, I'm guessing the apps are now configured to recreate the user session and push notification registration at least once a day.

One thing though, does this not happen on restart? So far users have reported restarting doesn't help.

tsightler avatar May 21 '23 13:05 tsightler

@dgreif @tsightler the theory about it impacting mostly EU users sounds plausible, most users of my app are in the European region. There are also some in Australia and New Zealand, I can contact a user from Australia and check with him. Btw, here’s my info, I’m collecting the rest of the information from other users and will post that later.

  1. When did you notice the problem? Around 12 may
  2. Did you remove all device and re-authenticate, if so, did this work and for how long? Yes, on three different Homeys, it worked between 24-48 hours
  3. What devices do you have? Ring Video Doorbell Pro 2, Ring Video Doorbell Pro, Stickup Cam, Indoor Cam
  4. What region/country are you located in? EU, the Netherlands
  5. Do you have a ring subscription? Yes

daneedk avatar May 21 '23 14:05 daneedk

Having the issue here as well. No dings and no motion events coming through to Homebridge. Ring App works. Node.js version is 18.16.0

  1. When did you notice the problem? Beginning of May

  2. Did you remove all device and re-authenticate, if so, did this work and for how long? Yes, worked for max 24 hours.

  3. What devices do you have? Ring Pro 2 wired and Ring 2 battery doorbells

  4. What region/country are you located in? EU, Germany

  5. Do you have a ring subscription? Yes

jchristianj avatar May 21 '23 15:05 jchristianj

I've released v11.7.6 which recreates the user session every 12 hours, and attaches the most recent push notification token whenever the session is recreated. I'd appreciate help testing this since I can't verify it within the US! Anyone who updates, please let me know if notifications stop working around the 24 hour mark still, otherwise hopefully we will know this is working in 2-3 days 🤞

One thing though, does this not happen on restart? So far users have reported restarting doesn't help.

Great question! The original setup actually didn't create a session (even on restart) unless we got a 404 back on a standard data request. Now I'm creating a session before any data requests go out, as well as on a 12 hour interval.

dgreif avatar May 21 '23 23:05 dgreif

For users of ring-mqtt that may be monitoring this issue, I've updated the dev branch to include 11.7.6 of ring-client-api to make this easier to test. Simply change the "branch" config option from "addon" to "dev" and restart the addon/docker container and it will pull down the latest dev branch for testing purposes. If this works I'll push out a full update later this week.

tsightler avatar May 21 '23 23:05 tsightler