Context deadline exceeded (Client.Timeout exceeded while awaiting headers)

Hi All - was hoping someone could help with an issue I’m having… I have a solution written in go using the Influx v2 API (github.com/influxdata/influxdb-client-go/v2). Unfortunately I need to perform some rather large queries and generate a report on the data, but am receiving a timeout error.

Query Error: Post “http://influx-server:8086/api/v2/query?org=”: context deadline exceeded (Client.Timeout exceeded while awaiting headers)

I have attempted to work around it by changing the client connection parameters, but no luck… Seems like it’s the context run by the client itself rather than the HTTP params…

Client Connection Code;

if db.Client = influx.NewClient(db.InfluxHost+“:”+db.InfluxPort, “”); db.Client != nil {
db.Client.Options().SetPrecision(time.Second)
db.Client.Options().SetHTTPRequestTimeout(900)
db.Client.Options().HTTPOptions().SetHTTPRequestTimeout(900)
} else {
logOut.Log(LOG_CRITICAL, “(DBInflux/Connect): ERROR - Unable to connect to database”)
return (&AppError{ERR_CRITICAL, “05-1000”, “Unable to connect to Influx Database”})
}

Timeout period stays at approx 20 seconds no matter what I change.
InfluxDB: Version 1.8.6, Standard influxdb container influxdb:1.8.6

Any suggestions / thoughts on what can be done here - if needed I can potentially split up the query into smaller parts, but would be much nicer if I can do it all in one…

Just to cover it all off - smaller period queries work fine - definitely related to how much data I’m attempting to pull back.

thoughts?

@ericw, custom options must be passed during client creation using NewClientWithOptions(). The later setting of connection related options doesn’t have an effect.

client := influxdb2.NewClientWithOptions("http://localhost:8086", "my-token", 
    influxdb2.DefaultOptions().
        SetPrecision(time.Second).
        SetHTTPRequestTimeout(900))
1 Like

Oops - should have figured that one out… :man_facepalming: you are 100% correct Vlasta - works like a charm. Thanks for the help!