fasthttp icon indicating copy to clipboard operation
fasthttp copied to clipboard

Error when serving connection "x.x.x.x:443"<->"172.56.198.126:18271": EOF

Open mlb4428675 opened this issue 1 year ago • 3 comments

Hi guys,

We use fasthttp to implement http and https services. From testing I find the http service can handle 20,000 QPS with about 40-45% CPU. However, I saw many https errors in the error log, but no http error. For example:

2024/04/14 15:18:34 error when serving connection "x.x.x.x:443"<->"24.239.113.227:64266": read tcp4 x.x.x.x:443->24.239.113.227:64266: i/o timeout
2024/04/14 15:18:34 error when serving connection "x.x.x.x:443"<->"209.239.103.95:48842": read tcp4 x.x.x.x:443->209.239.103.95:48842: i/o timeout
2024/04/14 15:18:38 error when serving connection "x.x.x.x:443"<->"73.37.175.237:55178": EOF
2024/04/14 15:18:38 error when serving connection "x.x.x.x:443"<->"73.50.53.66:54914": EOF
2024/04/14 15:18:39 error when serving connection "x.x.x.x:443"<->"2.219.251.200:63288": EOF
2024/04/14 15:18:40 error when serving connection "x.x.x.x:443"<->"108.145.161.68:21544": EOF
2024/04/14 15:18:45 error when serving connection "x.x.x.x:443"<->"172.56.198.126:18271": EOF
2024/04/14 15:18:45 error when serving connection "x.x.x.x:443"<->"76.99.128.124:52915": read tcp4 x.x.x.x:443->76.99.128.124:52915: i/o timeout
2024/04/14 15:18:45 error when serving connection "x.x.x.x:443"<->"194.223.42.125:51590": read tcp4 x.x.x.x:443->194.223.42.125:51590: i/o timeout
2024/04/14 15:18:47 error when serving connection "x.x.x.x:443"<->"161.216.164.35:57059": read tcp4 x.x.x.x:443->161.216.164.35:57059: i/o timeout
2024/04/14 15:18:48 error when serving connection "x.x.x.x:443"<->"165.165.120.93:60080": read tcp4 x.x.x.x:443->165.165.120.93:60080: i/o timeout
2024/04/14 15:18:48 error when serving connection "x.x.x.x:443"<->"76.145.183.220:54072": EOF
2024/04/14 15:18:52 error when serving connection "x.x.x.x:443"<->"74.56.40.3:50533": EOF
2024/04/14 15:18:52 error when serving connection "x.x.x.x:443"<->"216.152.187.86:50748": EOF
2024/04/14 15:18:52 error when serving connection "x.x.x.x:443"<->"161.216.164.152:39345": read tcp4 x.x.x.x:443->161.216.164.152:39345: i/o timeout
2024/04/14 15:18:53 error when serving connection "x.x.x.x:443"<->"96.234.173.11:55128": EOF
2024/04/14 15:18:53 error when serving connection "x.x.x.x:443"<->"76.49.122.157:56297": EOF
2024/04/14 15:18:54 error when serving connection "x.x.x.x:443"<->"71.7.113.91:61892": read tcp4 x.x.x.x:443->71.7.113.91:61892: read: connection reset by peer
2024/04/14 15:18:54 error when serving connection "x.x.x.x:443"<->"83.59.254.161:54836": EOF
2024/04/14 15:18:55 error when serving connection "x.x.x.x:443"<->"71.129.74.178:53145": EOF
2024/04/14 15:18:56 error when serving connection "x.x.x.x:443"<->"73.170.32.107:64919": EOF
2024/04/14 15:18:56 error when serving connection "x.x.x.x:443"<->"84.83.200.178:64587": EOF

The config information is here:

	httpsPort := ":443"
	httpsServer := &fasthttp.Server{
		Handler:        handler,
		IdleTimeout:    35 * time.Second,
		ReadTimeout:    30 * time.Second,
		WriteTimeout:   10 * time.Second,
		ReadBufferSize: 8 * 1024,
		Concurrency:    256 * 1024,
		TLSConfig:      tlsConfig,
		LogAllErrors:   true,
	}

	go func() {
		if err := httpsServer.ListenAndServeTLS(httpsPort, "", ""); err != nil {
			log.Fatalf("Error in HTTPS server: %s", err)
		}
	}()

I would like advice on how I can troubleshoot this error and resolve it. thanks!

mlb4428675 avatar Apr 14 '24 15:04 mlb4428675

It's hard to say. It could for example be http clients trying to connect to a https endpoint. It could be bots. It could be clients that can't handle certificate.

erikdubbelboer avatar Apr 14 '24 17:04 erikdubbelboer

thanks, but how can I get the whole URL of the request that has experienced such error, in error log, only a message "2024/04/14 15:18:38 error when serving connection "x.x.x.x:443"<->"73.37.175.237:55178": EOF".

mlb4428675 avatar Apr 15 '24 01:04 mlb4428675

The problem is that at this point you don't have a URL. It could happen at any point in the request cycle where maybe the URL hasn't been received yet.

It might be interesting to try and amend the errors here with a URL if that's already received: https://github.com/valyala/fasthttp/blob/d3aa5a15bb0131fe7e58e948cff8ee8ed748112e/header.go#L2714-L2724 But I'm afraid I don't have time to look into this at the moment. But I would be open to a pull request.

erikdubbelboer avatar Apr 15 '24 09:04 erikdubbelboer