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

Error 500 in Ring API on Homebridge #1431

Closed
1 task done
Bro-Rocket12 opened this issue Jun 18, 2024 · 49 comments · Fixed by #1433
Closed
1 task done

Error 500 in Ring API on Homebridge #1431

Bro-Rocket12 opened this issue Jun 18, 2024 · 49 comments · Fixed by #1433
Assignees
Labels
bug Something isn't working

Comments

@Bro-Rocket12
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe The Bug

Error 500 in Ring API. Ring plugin no longer works for this location. The entire homebridge crashed while I was viewing cams and not the ring plugin is stuck on this error for this location only. My other location id works fine.

To Reproduce

No response

Expected behavior

it should work

Relevant log output

[6/18/2024, 11:05:09 AM] [homebridge-ring] Request to https://app.ring.com/api/v1/clap/tickets?locationID=4c21be7e-8ccd-4aab-9c44-d5eab8609575 failed with status 500. Response body: {"error":860004,"msg":"No available app brokers"}
[6/18/2024, 11:05:09 AM] [homebridge-ring] Error connecting to API
[6/18/2024, 11:05:09 AM] [homebridge-ring] HTTPError: Response code 500 (Server Error)
    at Request.<anonymous> (/volume1/homebridge/node_modules/homebridge-ring/node_modules/got/dist/source/as-promise/index.js:118:42)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1718733909218,
    socket: 1718733909223,
    lookup: 1718733909237,
    connect: 1718733909278,
    secureConnect: 1718733909368,
    upload: 1718733909369,
    response: 1718733909464,
    end: 1718733909465,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 5,
      dns: 14,
      tcp: 41,
      tls: 90,
      request: 1,
      firstByte: 95,
      download: 1,
      total: 247
    }
  }
}

Screenshots

No response

Additional context

No response

OS

Homebridge/ Synology

Node.js Version

v20.9.0

NPM Version

n/a

ring-client-api

n/a

Operating System

n/a

@Bro-Rocket12 Bro-Rocket12 added the bug Something isn't working label Jun 18, 2024
@TepidAssassin

This comment was marked as duplicate.

@MystK

This comment was marked as duplicate.

@SlasherKG

This comment was marked as duplicate.

@MystK
Copy link

MystK commented Jun 18, 2024

Based on the http error code, it seems to be a Ring server-side issue. I researched and saw that this endpoint helps establish a socket connection. Maybe it'll fix itself over time. This probably isn't an issue with homebridge-ring, especially since @Bro-Rocket12 mentioned his other location works.

@ElCastillo1353

This comment was marked as duplicate.

@Bro-Rocket12
Copy link
Author

Yeah it's definitely something sever side. Rolling back to previous version does not fix it unfortunately. Nor does setting it up as a child bridge. It is weird that my other location id works though, not sure why one works and the other does not. Hopefully whatever the issue is gets fixed soon.

@tsightler
Copy link
Collaborator

tsightler commented Jun 18, 2024

Please don't post a lot of "me too" post here, that does nothing but fill the maintainers inbox with lots of messages while providing no additional value. If you are having the same issue and feel the need to express yourself, a "thumbs up" on the initial post is enough. Of course if you have details to add beyond what has already been posted, feel free to do so.

It's quite clear that this is a change in behavior of the Ring server side, what is not clear is if it is a permanent change, or a temporary issue. The ring-client-api code is using app.ring.com to request tickets for opening a websocket connection. Historically this URL load balanced requests to a pool of servers but as of some point today it is returning the error "No available app brokers".

The official Ring app appears to use prd-api-us.prd.rings.solutions and the Ring web console uses account.ring.com/api which is also used for requesting the ticket for the WebRTC control channel websocket as well. These both seem to be working, so it's possible Ring is simply disabling this functionality on the old app pool and we'll need to update ring-client-api to use the new URL.

We're likely in for a bumpy ride with the Ring API for the next few weeks as, due the the deprecation and imminent disabling of the legacy FCM APIs (not directly related to Ring, but used for push notifications), we're also in the middle of migrating to FCM v1 to be able to continue to receive push notifications. Unfortunately, this work has been challenging as it depends on upstream packages which had several limitations in the implementation that made it unsuitable for use with ring-client-api. I finally managed to get this working last night, but upgrading will require upstream to accept a small PR I've submitted, a complete re-authentication cycle will have to be completed, and perhaps more. This work is ongoing, but it's a race against the clock since the official disable data for the legacy FCM API is June 20th.

I've also noticed there are other changes happening, lots of backend APIs failing even in the official Ring app, my guess is they are doing some backend optimization and consolidation. We'll do our best to keep up with the changes, at least so far I've not seen any intentional attempt to block 3rd-party access, something I have long feared could happen, but providing 100% reliability for a reverse engineered API is simply not possible.

@tsightler
Copy link
Collaborator

tsightler commented Jun 18, 2024

I have confirmed that replacing app.ring.com with prd-api-us.prd.rings.solutions seems to work around the issue. As far as I can tell this is used only for ticket requests and for changing modes, so I need to investigate if mode changes work with this new URL as well, if so, it should be a simple change.

If any of you know what you are doing and are interested in manually working around the issue, you can edit node_modules/ring-client-api/lib/rest-client.js and replace appApiBaseUrl = 'https://app.ring.com/api/v1/' with appApiBaseUrl = 'https://prd-api-us.prd.rings.solutions/api/v1/' on line 22.

@t-flow-sash
Copy link

Just manually did the change. All statuses of all devices are back, camera streams work and Alarm status change including PIN challenge work. Awesome!

@tsightler
Copy link
Collaborator

Just manually did the change. All statuses of all devices are back, camera streams work and Alarm status change including PIN challenge work. Awesome!

Thanks for the confirmation, if someone out there happens to have a setup that uses modes, and can verify that the change doesn't break that, it would go a long way as I don't have an easy way to test this at the moment as I have an alarm at my location and I don't have any spare camera to setup a second site with no alarm.

@rorygallagher2024
Copy link

Hi, I made the change to update 'appApiBaseUrl' and it also worked for me. @tsightler - By modes, do you mean just switching my alarm to Home/Away modes, using the buttons as shown in the screenshot?

If so, that is working for me
Screenshot 2024-06-18 at 21 34 13

@jamesonuk
Copy link

Just going to add that I did worry about the US in that domain name and wondered if this was US specific but just checking DNS logs I can see that app in UK is still connecting to prd-api-us.prd.rings.solutions so would appear to be a global thing

@t-flow-sash

This comment was marked as duplicate.

@willliamchan
Copy link

Just manually did the change. All statuses of all devices are back, camera streams work and Alarm status change including PIN challenge work. Awesome!

Please, can you explain me how to do it? ( i don't know how to edit the node modules)

I am using ring-mqtt with docker and this is what I did.

  1. sudo docker exec -it ring-mqtt bash (this enter the console of the container
  2. cd ./app/ring-mqtt/node_modules/ring-client-api/lib
  3. vi rest-client.js

@rorygallagher2024
Copy link

rorygallagher2024 commented Jun 18, 2024

Just in case it helps anyone, I am using the ring-mqtt docker image and was able to modify the URL as follow.

First I had to access the container's shell on my home assistant server:
docker exec -it ring-mqtt /bin/sh

Then I searched for the rest-client.js file and found it at this location
/app/ring-mqtt/node_modules/ring-client-api/lib/rest-client.js

So I used vi to modify the file
vi /app/ring-mqtt/node_modules/ring-client-api/lib/rest-client.js

and then proceeded to modify the appApiBaseUrl value to https://prd-api-us.prd.rings.solutions/api/v1/

@jacobhopkins117
Copy link

Just manually did the change. All statuses of all devices are back, camera streams work and Alarm status change including PIN challenge work. Awesome!

Confirmed the change to appApiBaseUrl is working for me. Changing modes works as well.

@MystK
Copy link

MystK commented Jun 18, 2024

Just manually did the change. All statuses of all devices are back, camera streams work and Alarm status change including PIN challenge work. Awesome!

Please, can you explain me how to do it? ( i don't know how to edit the node modules)

  1. Go to homebridge UI terminal: something like http://192.168.1.11:8581/platform-tools/terminal
  2. look for Plugin Path in the terminal. Mine is /var/lib/homebridge/node_modules
  3. type in nano {PLUGIN_PATH}/homebridge-ring/node_modules/ring-client-api/lib/rest-client.js. Mine looks like nano /var/lib/homebridge/node_modules/homebridge-ring/node_modules/ring-client-api/lib/rest-client.js
  4. Use your arrow keys to go down to line 22. It looks like:
}, clientApiBaseUrl = 'https://api.ring.com/clients_api/', deviceApiBaseUrl = 'https://api.ring.com/devices/v1/', commandsApiBaseUrl = 'https://api.ring.com/commands/v1/', appApiBaseUrl = 'https://app.ring.com/api/v1/', apiVersion = 11;
  1. Delete appApiBaseUrl = 'https://app.ring.com/api/v1/' and type in appApiBaseUrl = 'https://prd-api-us.prd.rings.solutions/api/v1/'
  2. CTRL+X to Exit
  3. Y to save
  4. ENTER to confirm
  5. Restart bomebridge-ring child process or main process and it look at logs to confirm it works

@alessandroarosio1977
Copy link

Is it possible to have a new version of component with URL fixed? I’m not confident to make manually this edit with Advanced SSH in my HAOS

@t-flow-sash
Copy link

Is it possible to have a new version of component with URL fixed? I’m not confident to make manually this edit with Advanced SSH in my HAOS

I am pretty sure that this will come soon once confirmed that this change really has no negative side effects. It is clearly just a workaround to do this manually as a re-pull of the container image will undo this change anyway every time.

@r1si
Copy link

r1si commented Jun 18, 2024

vi /app/ring-mqtt/mode_modules/ring-client-api/lib/rest-client.js

node_modules not mode_modules.
vi /app/ring-mqtt/node_modules/ring-client-api/lib/rest-client.js

@tFC-Styles
Copy link

Spent a fair while doing the usual troubleshooting on this before I came across this thread a few hours ago. And having seen the comments thought I’d leave.

Since all the traffic of you guys making changes etc, I figured I’d do a full server reboot. As it looks like a DNS change on ring’a end, rather than anything else. (Server OS reboot not just service/app)

This appears to have fixed the issue for me.

Using raspberry pi running homebridge OS

@tsightler
Copy link
Collaborator

tsightler commented Jun 18, 2024

Folks, if you don't know how to edit files, then the manual solution is not for you, newbies will have to wait for an official fix, having everybody post here about how to edit files will just add confusion. I will be deleting messages asking for help editing files, Google can help you, or you can go and talk about it in the discussions groups, but this is not the place for that, this issue is about researching and solving the problem.

@neilmartin83
Copy link

neilmartin83 commented Jun 18, 2024

Home Assistant: Confirmed working in the UK, using a Ring account that is not the "master" either. On HAOS, I made the edits and restarted the docker container.

  1. Install the Advanced SSH & Terminal add-on and configure it correctly (with a password)
  2. Disable Protected mode on the add-on config
  3. Launch the add-on and run: docker exec -it $(docker ps | grep ring-mqtt | awk '{print $1}') /bin/sh
  4. Edit this file: vi /app/ring-mqtt/node_modules/ring-client-api/lib/rest-client.js

If you're new to vi, use the cursor arrow keys to navigate towards the end of line 22, type a then replace appApiBaseUrl = 'https://app.ring.com/api/v1/' with appApiBaseUrl = 'https://prd-api-us.prd.rings.solutions/api/v1/' then press esc followed by entering :wq and press enter to save.

  1. Log out of the container with ctrl + d
  2. Restart the container, preserving your changes with: docker restart $(docker ps | grep ring-mqtt | awk '{print $1}')

If you screw it up, just restart the ring-mqtt add-on from the Home Assistant GUI and it will revert the damage and go back to its original state.

Repository owner deleted a comment from ThaShadow00 Jun 18, 2024
Repository owner deleted a comment from t-flow-sash Jun 18, 2024
@tsightler
Copy link
Collaborator

Just going to add that I did worry about the US in that domain name and wondered if this was US specific but just checking DNS logs I can see that app in UK is still connecting to prd-api-us.prd.rings.solutions so would appear to be a global thing

Thanks, I had this concern too, but I scoured the app source code and could not find any other reference to a non-US URL so I suspected it was not a problem.

@ThaShadow00
Copy link

Just manually did the change. All statuses of all devices are back, camera streams work and Alarm status change including PIN challenge work. Awesome!

Please, can you explain me how to do it? ( i don't know how to edit the node modules)

  1. Go to homebridge UI terminal: something like http://192.168.1.11:8581/platform-tools/terminal
  2. look for Plugin Path in the terminal. Mine is /var/lib/homebridge/node_modules
  3. type in nano {PLUGIN_PATH}/homebridge-ring/node_modules/ring-client-api/lib/rest-client.js. Mine looks like nano /var/lib/homebridge/node_modules/homebridge-ring/node_modules/ring-client-api/lib/rest-client.js
  4. Use your arrow keys to go down to line 22. It looks like:
}, clientApiBaseUrl = 'https://api.ring.com/clients_api/', deviceApiBaseUrl = 'https://api.ring.com/devices/v1/', commandsApiBaseUrl = 'https://api.ring.com/commands/v1/', appApiBaseUrl = 'https://app.ring.com/api/v1/', apiVersion = 11;
  1. Delete appApiBaseUrl = 'https://app.ring.com/api/v1/' and type in appApiBaseUrl = 'https://prd-api-us.prd.rings.solutions/api/v1/'
  2. CTRL+X to Exit
  3. Y to save
  4. ENTER to confirm
  5. Restart bomebridge-ring child process or main process and it look at logs to confirm it works

THANK YOU, it works

Repository owner deleted a comment from bditter Jun 18, 2024
Repository owner deleted a comment from ThaShadow00 Jun 18, 2024
Repository owner deleted a comment from jrdwiz Jun 18, 2024
@r1si
Copy link

r1si commented Jun 18, 2024

Proposal:
But what if we set a url we, which automatically links to the correct API url?
That way in a situation with today's, we could globally change the url and the whole thing would be solved, without requiring a new plugin update

@neildsb
Copy link

neildsb commented Jun 18, 2024

this worked - tsightler/ring-mqtt#861 (comment)

changing the volume only on the base station

@Tofusito
Copy link

I made another workaround without changing the source code, I changed the /etc/hosts and added this line:

app.ring.com prd-api-us.prd.rings.solutions

Restarted the complement and all is working fine for me. Alarm, sensor, etc..

@tsightler
Copy link
Collaborator

Proposal: But what if we set a url we, which automatically links to the correct API url? That way in a situation with today's, we could globally change the url and the whole thing would be solved, without requiring a new plugin update

I appreciate the suggestion, but the Ring API is complex, it's not just a single URL, there are at least a dozen different URLs listed in the code, it makes zero sense to try to expose them all. Many times when they change the API itself also changes, what headers are needed, what authentication they use, etc.

@tsightler
Copy link
Collaborator

I made another workaround without changing the source code, I changed the /etc/hosts and added this line:

app.ring.com prd-api-us.prd.rings.solutions

Restarted the complement and all is working fine for me. Alarm, sensor, etc..

Good idea and nice workaround for the interim.

@nicks123
Copy link

nicks123 commented Jun 18, 2024

If your running Pihole can change the CNAME record to redirect until a better solution is found

@jimloki
Copy link

jimloki commented Jun 18, 2024

Everything is working again, with no modifications. I just restarted the addon in Home Assistant

@Tofusito
Copy link

Everything is working again, with no modifications. I just restarted the addon in Home Assistant

No change in the hosts file or in the code? Maybe ring recover the previous url?

@broyuken
Copy link

yep works for me again too, just restarted the addon and it's good again

@jimloki
Copy link

jimloki commented Jun 18, 2024

Everything is working again, with no modifications. I just restarted the addon in Home Assistant

No change in the hosts file or in the code? Maybe ring recover the previous url?

Yes, I think so

@Tofusito
Copy link

Everything is working again, with no modifications. I just restarted the addon in Home Assistant

No change in the hosts file or in the code? Maybe ring recover the previous url?

Yes, I think so

Yup, I reverted my change, restarted the addon and it's working! No change in the code needed I guess

@tsightler
Copy link
Collaborator

tsightler commented Jun 18, 2024

As I stated earlier, it was quite likely the problem was temporary on the Ring side, the service errored with a message indicating a backend problem, not that it didn't exist or anything like that, it seemed likely to be temporary. That being said, it doesn't mean we shouldn't update the URL at some point to use the same one the Ring app leverages, otherwise it creates issues like this where the Ring app works while the projects depending on ring-client-api do not and people go crazy like they did here.

@qoodanny
Copy link

Rollling Back To v 11.8.1 solve the issue

@tsightler
Copy link
Collaborator

Rollling Back To v 11.8.1 solve the issue

No it won't, it's just that the outage is over and Ring has corrected the issue.

@jimloki
Copy link

jimloki commented Jun 18, 2024

Here we go again! It does not work anymore... (without the modification)

@TNOTA
Copy link

TNOTA commented Jun 18, 2024

I did the modification to the file and everything works perfectly, in fact my Ring cameras come up instantly in HomeKit now.

BUT I tried going back to the pre modified rest-client.js file when others said it was working again, and I am still getting error 500.

So I went back again to the modified file and it all works. So this issue may not be cleared on Rings end of things.

@tsightler
Copy link
Collaborator

Yes, there have been several periods of time where it worked or didn't work throughout the day. I guess we'll see if it stabilizes and, if not, we'll have to push out an update.

@ahaverty
Copy link

Just fyi for anyone else not back yet, I'm now getting a "Response code 503 (Service Unavailable)"

I'm in Ireland, so presumably Ring/DNS are slowly propogating a fix.

@tomiy1
Copy link

tomiy1 commented Jun 18, 2024

I restarted HB plugin, disabled and re-enabled it... no go still here. Am i supposed to do something else? thanks in advance!

@tsightler
Copy link
Collaborator

There is nothing to do until Ring either fixes the issue, or we push out a new version to work around the problem, unless you are able to implement one of the workarounds already posted in this thread.

@tomiy1
Copy link

tomiy1 commented Jun 18, 2024

which workaround is the "goto" atm? thank ya @tsightler !

this is an easy one:
I made another workaround without changing the source code, I changed the /etc/hosts and added this line:
app.ring.com prd-api-us.prd.rings.solutions

@tsightler
Copy link
Collaborator

tsightler commented Jun 18, 2024

Yes, that is probably the easiest and has no negative side effects, setting a DNS alias for app.ring.com to resolve to prd-api-us.prd.rings.solutions is probably the easiest, using either /etc/hosts or perhaps DNS on your local router, etc.

@tomiy1
Copy link

tomiy1 commented Jun 18, 2024

/etc/hosts is easy enough, ill give that a shot! Thanks @tsightler

Update: Worked like a charm (for now) ... thanks again!

@tsightler tsightler self-assigned this Jun 19, 2024
@tsightler tsightler linked a pull request Jun 19, 2024 that will close this issue
@tsightler
Copy link
Collaborator

12.1.1 has been released with a fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.