fix issue #21: add connection error handling