Skip to content

Commit 6ac5f7b

Browse files
DEVPROD-11824 Use custom dialer and set max connection idle time for mongo driver (#8824)
1 parent efd6347 commit 6ac5f7b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

config.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package evergreen
33
import (
44
"context"
55
"fmt"
6+
"net"
67
"net/http"
78
"os"
89
"path/filepath"
@@ -658,11 +659,19 @@ func (s *DBSettings) mongoOptions(url string) *options.ClientOptions {
658659
SetReadConcern(s.ReadConcernSettings.Resolve()).
659660
SetTimeout(mongoTimeout).
660661
SetConnectTimeout(mongoConnectTimeout).
662+
SetMaxConnIdleTime(30 * time.Second).
661663
SetMonitor(apm.NewMonitor(apm.WithCommandAttributeDisabled(false), apm.WithCommandAttributeTransformer(redactSensitiveCollections))).
662664
SetBSONOptions(&options.BSONOptions{
663665
ObjectIDAsHexString: true,
664666
})
665667

668+
dialer := &net.Dialer{
669+
Timeout: 30 * time.Second,
670+
KeepAlive: 300 * time.Second,
671+
}
672+
673+
opts.SetDialer(dialer)
674+
666675
if s.AWSAuthEnabled {
667676
opts.SetAuth(options.Credential{
668677
AuthMechanism: awsAuthMechanism,

0 commit comments

Comments
 (0)