Still getting closed connections at random times, as far as I can tell this code is not needed, and when I remove it, it appears to fix the random closed connection issues.