Added a reconnect-on-error feature.