@@ -100,10 +100,15 @@ internal async Task ReconnectAsync()
100
100
int randomWait = Random . Shared . Next ( 300 , 900 ) ;
101
101
Trace . WriteLine ( TraceLevel . Information , $ "{ ToString ( ) } is reconnecting in { randomWait } ms, " +
102
102
$ "attempt: { _backOffDelayPolicy . CurrentAttempt } ") ;
103
- await Task . Delay ( randomWait ) . ConfigureAwait ( false ) ;
104
- await OpenAsync ( ) . ConfigureAwait ( false ) ;
103
+ await Task . Delay ( randomWait )
104
+ . ConfigureAwait ( false ) ;
105
+
106
+ await OpenAsync ( )
107
+ . ConfigureAwait ( false ) ;
108
+
105
109
Trace . WriteLine ( TraceLevel . Information ,
106
110
$ "{ ToString ( ) } is reconnected, attempt: { _backOffDelayPolicy . CurrentAttempt } ") ;
111
+
107
112
_backOffDelayPolicy . Reset ( ) ;
108
113
}
109
114
catch ( Exception e )
@@ -112,11 +117,15 @@ internal async Task ReconnectAsync()
112
117
// that's an edge case, where the link is not ready for some reason
113
118
// the backoff policy will be used to delay the reconnection and give just a few attempts
114
119
Trace . WriteLine ( TraceLevel . Error , $ "{ ToString ( ) } Failed to reconnect, { e . Message } ") ;
120
+
115
121
int delay = _backOffDelayPolicy . Delay ( ) ;
116
- await Task . Delay ( delay ) . ConfigureAwait ( false ) ;
122
+ await Task . Delay ( delay )
123
+ . ConfigureAwait ( false ) ;
124
+
117
125
if ( _backOffDelayPolicy . IsActive ( ) )
118
126
{
119
- await ReconnectAsync ( ) . ConfigureAwait ( false ) ;
127
+ await ReconnectAsync ( )
128
+ . ConfigureAwait ( false ) ;
120
129
}
121
130
}
122
131
}
0 commit comments