Added a check for connectivity so node won't crash when an endpoint is unreachable.