I found a similar situation when going through a firewall.
The connection would disconnect only when idle for a certain amount of time. It was definitely not on the server or database side, but had to do with the firewall configs.

Once we moved the server inside the firewall the disconnects dissapeared.