Added SSL and reconnect logic.