dapr / dapr

Dapr is a portable, event-driven, runtime for building distributed applications across cloud and edge.
https://dapr.io
Apache License 2.0
23.54k stars 1.85k forks source link

App channel HTTP client not setting `IdleConnTimeout` #7832

Closed alicejgibbons closed 1 week ago

alicejgibbons commented 1 week ago

In what area(s)?

/area runtime

/area operator

/area placement

/area docs

/area test-and-release

What version of Dapr?

1.13.4

1.1.x 1.0.x edge: output of git describe --dirty

Actual Behavior

Today when the Dapr app channel HTTP client is created in the Dapr runtime, its not setting a default idle connection timeout property, meaning that the zero value is being set which allows for no limit on the amount of time a connection can remain idle before closing: https://cs.opensource.google/go/go/+/refs/tags/go1.22.4:src/net/http/transport.go;l=221

See the transport object being created in Dapr here which is overwriting any sane defaults set by go.

Expected Behavior

The IdleConnTimeout property should be set so that idle connections are closed eventually. Maybe using the default of 90 seconds set by go: https://cs.opensource.google/go/go/+/refs/tags/go1.22.4:src/net/http/transport.go;l=43

Steps to Reproduce the Problem

Service invocation between two apps with the invokee app server setting a low (~10 ms) HTTP connection keep-alive value. By constantly invoking the app, you can see various instances of the following errors: " err: rpc error: code = Internal desc = error invoking app channel":

By setting a idleConnectionTimeout value in the app channel, this will allow the user to configure their invokee app to set the idle-connection/keep-alive timeout higher than that of Dapr's.

Release Note

RELEASE NOTE: FIX set idle connection timeout in HTTP app channel.