From c45269285c71dd9a9cb07e5f8dbf32e0181e203b Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 6 Aug 2020 15:05:17 +0100 Subject: [PATCH] Disable HTTP connection reuse, tweak timeouts --- build/gobind/monolith.go | 6 +++--- cmd/dendrite-demo-yggdrasil/main.go | 6 +++--- cmd/dendrite-demo-yggdrasil/yggconn/client.go | 12 ++++++++---- cmd/dendrite-demo-yggdrasil/yggconn/node.go | 7 +------ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/build/gobind/monolith.go b/build/gobind/monolith.go index 98d2e5aa0..c0c0ccb43 100644 --- a/build/gobind/monolith.go +++ b/build/gobind/monolith.go @@ -188,9 +188,9 @@ func (m *DendriteMonolith) Start() { m.httpServer = &http.Server{ Addr: ":0", TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){}, - ReadTimeout: 15 * time.Second, - WriteTimeout: 45 * time.Second, - IdleTimeout: 60 * time.Second, + ReadTimeout: 10 * time.Second, + WriteTimeout: 10 * time.Second, + IdleTimeout: 30 * time.Second, BaseContext: func(_ net.Listener) context.Context { return context.Background() }, diff --git a/cmd/dendrite-demo-yggdrasil/main.go b/cmd/dendrite-demo-yggdrasil/main.go index a778a5880..81bf994b2 100644 --- a/cmd/dendrite-demo-yggdrasil/main.go +++ b/cmd/dendrite-demo-yggdrasil/main.go @@ -174,9 +174,9 @@ func main() { httpServer := &http.Server{ Addr: ":0", TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){}, - ReadTimeout: 15 * time.Second, - WriteTimeout: 45 * time.Second, - IdleTimeout: 60 * time.Second, + ReadTimeout: 10 * time.Second, + WriteTimeout: 10 * time.Second, + IdleTimeout: 30 * time.Second, BaseContext: func(_ net.Listener) context.Context { return context.Background() }, diff --git a/cmd/dendrite-demo-yggdrasil/yggconn/client.go b/cmd/dendrite-demo-yggdrasil/yggconn/client.go index c5b3eb722..56afe264d 100644 --- a/cmd/dendrite-demo-yggdrasil/yggconn/client.go +++ b/cmd/dendrite-demo-yggdrasil/yggconn/client.go @@ -24,9 +24,11 @@ func (n *Node) CreateClient( tr.RegisterProtocol( "matrix", &yggroundtripper{ inner: &http.Transport{ - TLSHandshakeTimeout: 20 * time.Second, + MaxIdleConns: -1, + MaxIdleConnsPerHost: -1, + TLSHandshakeTimeout: 10 * time.Second, ResponseHeaderTimeout: 10 * time.Second, - IdleConnTimeout: 60 * time.Second, + IdleConnTimeout: 30 * time.Second, DialContext: n.DialerContext, }, }, @@ -41,9 +43,11 @@ func (n *Node) CreateFederationClient( tr.RegisterProtocol( "matrix", &yggroundtripper{ inner: &http.Transport{ - TLSHandshakeTimeout: 20 * time.Second, + MaxIdleConns: -1, + MaxIdleConnsPerHost: -1, + TLSHandshakeTimeout: 10 * time.Second, ResponseHeaderTimeout: 10 * time.Second, - IdleConnTimeout: 60 * time.Second, + IdleConnTimeout: 30 * time.Second, DialContext: n.DialerContext, TLSClientConfig: n.tlsConfig, }, diff --git a/cmd/dendrite-demo-yggdrasil/yggconn/node.go b/cmd/dendrite-demo-yggdrasil/yggconn/node.go index b0fb4d14f..9b123aa64 100644 --- a/cmd/dendrite-demo-yggdrasil/yggconn/node.go +++ b/cmd/dendrite-demo-yggdrasil/yggconn/node.go @@ -98,11 +98,6 @@ func Setup(instanceName, storageDirectory string) (*Node, error) { fmt.Println("COORDINATE CHANGE!") fmt.Println("Old:", old) fmt.Println("New:", new) - n.coords.Range(func(k, _ interface{}) bool { - fmt.Println("Deleting cached coords for", k) - n.coords.Delete(k) - return true - }) n.sessions.Range(func(k, v interface{}) bool { if s, ok := v.(*session); ok { fmt.Println("Killing session", k) @@ -214,7 +209,7 @@ func (n *Node) KnownNodes() []gomatrixserverlib.ServerName { } /* for _, peer := range n.core.GetSwitchPeers() { - nodemap[hex.EncodeToString(peer.SigningKey[:])] = struct{}{} + nodemap[hex.EncodeToString(peer.PublicKey[:])] = struct{}{} } */ n.sessions.Range(func(_, v interface{}) bool {