do not crash on failed connect
Merge pull request #45 from seletskiy/master

do not crash on failed connect
golint/gofmt the code