Disable HTTP connection reuse, tweak timeouts

This commit is contained in:
Neil Alexander 2020-08-06 15:05:17 +01:00
parent f15a96bec0
commit c45269285c
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 15 additions and 16 deletions

View file

@ -188,9 +188,9 @@ func (m *DendriteMonolith) Start() {
m.httpServer = &http.Server{ m.httpServer = &http.Server{
Addr: ":0", Addr: ":0",
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){}, TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
ReadTimeout: 15 * time.Second, ReadTimeout: 10 * time.Second,
WriteTimeout: 45 * time.Second, WriteTimeout: 10 * time.Second,
IdleTimeout: 60 * time.Second, IdleTimeout: 30 * time.Second,
BaseContext: func(_ net.Listener) context.Context { BaseContext: func(_ net.Listener) context.Context {
return context.Background() return context.Background()
}, },

View file

@ -174,9 +174,9 @@ func main() {
httpServer := &http.Server{ httpServer := &http.Server{
Addr: ":0", Addr: ":0",
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){}, TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
ReadTimeout: 15 * time.Second, ReadTimeout: 10 * time.Second,
WriteTimeout: 45 * time.Second, WriteTimeout: 10 * time.Second,
IdleTimeout: 60 * time.Second, IdleTimeout: 30 * time.Second,
BaseContext: func(_ net.Listener) context.Context { BaseContext: func(_ net.Listener) context.Context {
return context.Background() return context.Background()
}, },

View file

@ -24,9 +24,11 @@ func (n *Node) CreateClient(
tr.RegisterProtocol( tr.RegisterProtocol(
"matrix", &yggroundtripper{ "matrix", &yggroundtripper{
inner: &http.Transport{ inner: &http.Transport{
TLSHandshakeTimeout: 20 * time.Second, MaxIdleConns: -1,
MaxIdleConnsPerHost: -1,
TLSHandshakeTimeout: 10 * time.Second,
ResponseHeaderTimeout: 10 * time.Second, ResponseHeaderTimeout: 10 * time.Second,
IdleConnTimeout: 60 * time.Second, IdleConnTimeout: 30 * time.Second,
DialContext: n.DialerContext, DialContext: n.DialerContext,
}, },
}, },
@ -41,9 +43,11 @@ func (n *Node) CreateFederationClient(
tr.RegisterProtocol( tr.RegisterProtocol(
"matrix", &yggroundtripper{ "matrix", &yggroundtripper{
inner: &http.Transport{ inner: &http.Transport{
TLSHandshakeTimeout: 20 * time.Second, MaxIdleConns: -1,
MaxIdleConnsPerHost: -1,
TLSHandshakeTimeout: 10 * time.Second,
ResponseHeaderTimeout: 10 * time.Second, ResponseHeaderTimeout: 10 * time.Second,
IdleConnTimeout: 60 * time.Second, IdleConnTimeout: 30 * time.Second,
DialContext: n.DialerContext, DialContext: n.DialerContext,
TLSClientConfig: n.tlsConfig, TLSClientConfig: n.tlsConfig,
}, },

View file

@ -98,11 +98,6 @@ func Setup(instanceName, storageDirectory string) (*Node, error) {
fmt.Println("COORDINATE CHANGE!") fmt.Println("COORDINATE CHANGE!")
fmt.Println("Old:", old) fmt.Println("Old:", old)
fmt.Println("New:", new) 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 { n.sessions.Range(func(k, v interface{}) bool {
if s, ok := v.(*session); ok { if s, ok := v.(*session); ok {
fmt.Println("Killing session", k) fmt.Println("Killing session", k)
@ -214,7 +209,7 @@ func (n *Node) KnownNodes() []gomatrixserverlib.ServerName {
} }
/* /*
for _, peer := range n.core.GetSwitchPeers() { 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 { n.sessions.Range(func(_, v interface{}) bool {