fix panic on connection error