improbe connection error handling

This patch fixes exception error on connection failed .
Would you please merge this patch?

exception:
`undefined method 'include?' for nil (NoMethodError)`