fix bug in connection retry