Home >Backend Development >Golang >packet.go:123: Error closing idle connection: connection reset by peer
When doing network programming, we often encounter some errors, including "packet.go:123: Bad idle connection closed: The connection was reset by the peer" error message. This error usually means that the connecting party accidentally closed the connection, rendering the current connection invalid. It is very important for developers to resolve such errors. In this article, PHP editor Xigua will introduce how to deal with and solve this problem to ensure the stability and reliability of network programming.
I use go, fiber web framework, mariadb 10.6, debian 11 and github.com/go-sql-driver/mysql
to connect to mariadb. I have used these settings
db.setmaxopenconns(25) db.setmaxidleconns(25) db.setconnmaxlifetime(5 * time.minute)
i.e. I increase the value, decrease the value, but still get 1 or 2 warnings
packets.go:123: closing bad idle connection: connection reset by peer
every minute. Any suggestions?
The answer is that my wait_timeout is 20 seconds and the interaction timeout is 50 seconds. I have now increased its fixed value. Thanks to @ysth for the solution.
The answer is me The wait_timeout is 20 seconds and the interaction timeout is 50 seconds, I have increased it now, thanks to @ysth for the solution
The above is the detailed content of packet.go:123: Error closing idle connection: connection reset by peer. For more information, please follow other related articles on the PHP Chinese website!