Encapsulate connection and add idle timeout handling