client-go icon indicating copy to clipboard operation
client-go copied to clipboard

Timeout exceeded

Open nathanhack opened this issue 11 months ago • 0 comments

Describe the bug https://github.com/polygon-io/client-go/blob/fb8e9d4845ca5e86e464919e4e864efa62e06304/rest/client/client.go#L48 The timout is set too low for queries like the following: https://api.polygon.io/v3/reference/options/contracts?underlying_ticker=QQQ&expired=true&limit=1000

Results in this error being printed to the screen:

 WARN RESTY Get .... context deadline exceeded (Client.Timeout exceeded while awaiting headers)

After several attempts it fails out with:

 failed to execute request: Get "https://api.polygon.io/v3/reference/options/contracts?expired=true&limit=1000&underlying_ticker=QQQ": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

To Reproduce

params := models.ListOptionsContractsParams{}.
			WithExpired(expired).
			WithLimit(1000).
			WithUnderlyingTicker("QQQ")

iter := client.ReferenceClient.ListOptionsContracts(context.Background(), params)
items := make([]models.OptionsContract, 500_000)
for iter.Next() {
       items = append(items, iter.Item())
}

Additional context

After increasing from 10 seconds to 60 seconds there are no errors are printed to the screen and it successfully downloads the contracts. This also occurs when I use the option quotes endpoint as well. This issue is a problem across multiple endpoints using the golang lib.

nathanhack avatar Feb 17 '25 04:02 nathanhack