ring icon indicating copy to clipboard operation
ring copied to clipboard

Error 500 in Ring API on Homebridge

Open Bro-Rocket12 opened this issue 2 years ago • 49 comments

Is there an existing issue for this?

  • [X] 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 avatar Jun 18 '24 18:06 Bro-Rocket12

I am also experiencing the same issue after updating Homebridge today;

[18/06/2024, 19:08:04] [homebridge-ring] Request to https://app.ring.com/api/v1/clap/tickets?locationID=cc415c7-30c8-497f-b2c0-5bb94de8103d failed with status 500. Response body: {"error":860004,"msg":"No available app brokers"} [18/06/2024, 19:08:04] [homebridge-ring] Error connecting to API [18/06/2024, 19:08:04] [homebridge-ring] HTTPError: Response code 500 (Server Error) at Request. (/var/lib/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: 1718734084301, socket: 1718734084303, lookup: 1718734084316, connect: 1718734084399, secureConnect: 1718734084570, upload: 1718734084571, response: 1718734084713, end: 1718734084713, error: undefined, abort: undefined, phases: { wait: 2, dns: 13, tcp: 83, tls: 171, request: 1, firstByte: 142, download: 0, total: 412 } } }

TepidAssassin avatar Jun 18 '24 18:06 TepidAssassin

started happening to me today or recently also. Didn't do any updates in the last few weeks.

Node.js Version | v20.14.0 homebridge-ring | v12.1.0

MystK avatar Jun 18 '24 18:06 MystK

Same error here. No updates done recently.

Hopefully this can be fixed or is just temporary.

SlasherKG avatar Jun 18 '24 18:06 SlasherKG

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.

MystK avatar Jun 18 '24 18:06 MystK

Same....

[6/18/2024, 1:33:17 PM] [Ring] Request to https://app.ring.com/api/v1/clap/tickets?locationID=baa71e2c-7986-44fa-744e-720cff98e320 failed with status 500. Response body: {"error":860004,"msg":"No available app brokers"} [6/18/2024, 1:33:17 PM] [Ring] Error connecting to API [6/18/2024, 1:33:17 PM] [Ring] HTTPError: Response code 500 (Server Error) at Request. (/var/lib/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',

ElCastillo1353 avatar Jun 18 '24 18:06 ElCastillo1353

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.

Bro-Rocket12 avatar Jun 18 '24 18:06 Bro-Rocket12

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 avatar Jun 18 '24 19:06 tsightler

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.

tsightler avatar Jun 18 '24 19:06 tsightler

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

t-flow-sash avatar Jun 18 '24 20:06 t-flow-sash

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.

tsightler avatar Jun 18 '24 20:06 tsightler

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

rorygallagher2024 avatar Jun 18 '24 20:06 rorygallagher2024

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

jamesonuk avatar Jun 18 '24 20:06 jamesonuk

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 in a docker container. Just jumped into the interactive shell of that container and followed the path given by @tsightler and did the change in line 22

t-flow-sash avatar Jun 18 '24 20:06 t-flow-sash

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

willliamchan avatar Jun 18 '24 20:06 willliamchan

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/

rorygallagher2024 avatar Jun 18 '24 20:06 rorygallagher2024

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.

jacobhopkins117 avatar Jun 18 '24 20:06 jacobhopkins117

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

MystK avatar Jun 18 '24 20:06 MystK

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

alessandroarosio1977 avatar Jun 18 '24 20:06 alessandroarosio1977

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.

t-flow-sash avatar Jun 18 '24 20:06 t-flow-sash

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

r1si avatar Jun 18 '24 21:06 r1si