# Intermittent connection issues to DB server

**URL:** <https://forums.percona.com/t/intermittent-connection-issues-to-db-server/5536>\
**Category:** Other MySQL® Questions\
**Created:** [April 10, 2017, 10:29am UTC](https://forums.percona.com/t/intermittent-connection-issues-to-db-server/5536 "2017-04-10T10:29:58Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![apapsch](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@apapsch](https://forums.percona.com/u/apapsch)\
**Post date:** [December 11, 2018, 11:05am UTC](https://forums.percona.com/t/intermittent-connection-issues-to-db-server/5536/3 "2018-12-11T11:05:15Z")

</div>

Do you by chance use connections for a rather long time? I had a similar problem in a daemon that employed a connection for hours (if not days). Once the connection becomes unused, the connection is closed after a timeout. This should not be an issue specific to the .NET connector. You’ll also experience this e.g. in Go programs or even long running PHP scripts (given the connection becomes idle every once in a while).

You have several options:  
[LIST]  
[_]Increase the timeouts (there may also be a driver specific way to do this). You’ll want to set this higher than the expected idle times. A downside of this is that connections can accumulate (depending how your app is structured, for a lone daemon with just one connection it may not have much of an impact).  
SET SESSION wait\_timeout=x  
SET SESSION net\_read\_timeout=x  
SET SESSION net\_write\_timeout=x  
[_]Use a connection pool that’s responsible for maintaining connections. The pool should be a component of your app. If your driver is really good, it provides a pool for you.  
[\*]Somewhat related to the pool: Implement automated reconnects. I’d recommend the pool however.  
[/LIST]

---

_[View the full topic](https://forums.percona.com/t/intermittent-connection-issues-to-db-server/5536)._
