Fixing issue where timeout occurs after socket close in client