Long-lived clients get ECONNRESET, EPIPE, or just nils from TCPSocket. Use TCP keepalives, or even keepalive messages.