$ npm install when-connected
perform a callback when "connected" or fire callback with timeout error if its taken too long.