Skip to content

Commit

Permalink
Disable keepalive and increase connect timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Sightler committed Nov 2, 2024
1 parent c4c3526 commit eabdc63
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/ring-client-api/rest-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { ReplaySubject } from 'rxjs'
import assert from 'assert'
import type { Credentials } from '@eneris/push-receiver/dist/types'
import { Agent as HttpsAgent } from 'node:https'

interface RequestOptions extends RequestInit {
responseType?: 'json' | 'buffer'
Expand All @@ -39,7 +40,11 @@ const defaultRequestOptions: RequestOptions = {
deviceApiBaseUrl = 'https://api.ring.com/devices/v1/',
commandsApiBaseUrl = 'https://api.ring.com/commands/v1/',
appApiBaseUrl = 'https://prd-api-us.prd.rings.solutions/api/v1/',
apiVersion = 11
apiVersion = 11,
agent = new HttpsAgent({
timeout: 20000,
keepAlive: false,
})

export function clientApi(path: string) {
return clientApiBaseUrl + path
Expand Down Expand Up @@ -110,6 +115,7 @@ async function requestWithRetry<T>(
const options = {
...defaultRequestOptions,
...requestOptions,
agent,
}

// If a timeout is provided, create an AbortSignal for it
Expand Down Expand Up @@ -499,6 +505,7 @@ export class RingRestClient {
authorization: `Bearer ${authTokenResponse.access_token}`,
hardware_id: hardwareId,
'User-Agent': 'android:com.ringapp',
Connection: 'close',
},
})
} catch (e: any) {
Expand Down

0 comments on commit eabdc63

Please sign in to comment.