What could cause "accept tcp [::]:42796: i/o timeout" on listener.Accept()?

106 views
Skip to first unread message

whileloop

unread,
Oct 25, 2023, 1:00:11 PM10/25/23
to golang-nuts
Hi community,

I am quite stumped by this error that I am getting intermittently on my Go server running on Ubuntu.

The following code logs the error:
conn, err := listener.Accept()
if err != nil {
log.Error(err)
}


Output:
accept tcp [::]:42796: i/o timeout

I have never seen an i/o timeout on accept before and I don't know what it could mean. Is this being caused by a resource constraint on my server or is it because the client is not sending data?

Thanks,
whileloop

Taj Khattra

unread,
Oct 25, 2023, 3:23:17 PM10/25/23
to golang-nuts
Accept() can return an "i/o timeout" (os.ErrDeadlineExceeded) if your listener has set a deadline via SetDeadline() (e.g. https://pkg.go.dev/net#TCPListener.SetDeadline for a TCP listener)
Reply all
Reply to author
Forward
0 new messages