Closed Gsantomaggio closed 9 months ago
@simone-fariselli will follow this issue.
Hi @Gsantomaggio, I created the following method in the Client class:
internal async Task UpdateSecret()
{
var saslHandshakeResponse =
await Request<SaslHandshakeRequest, SaslHandshakeResponse>(corr => new SaslHandshakeRequest(corr))
.ConfigureAwait(false);
_logger?.LogDebug("Sasl mechanism: {Mechanisms}", saslHandshakeResponse.Mechanisms);
var saslData = Encoding.UTF8.GetBytes($"\0{Parameters.UserName}\0{Parameters.Password}");
var authResponse =
await Request<SaslAuthenticateRequest, SaslAuthenticateResponse>(corr =>
new SaslAuthenticateRequest(corr, Parameters.AuthMechanism.ToString().ToUpperInvariant(),
saslData))
.ConfigureAwait(false);
ClientExceptions.MaybeThrowException(authResponse.ResponseCode, Parameters.UserName);
}
which should handle the change of secret (i.e of the access_token).
I get an applicative timeout and the following error log from the server:
unknown command {request,101,
{sasl_authenticate,<<"PLAIN">>,
<<0,103,117,101,115,116,0,103,117,101,115,116>>}}, sending close command.
Ignored unknown message emit_stats in state close_sent
Closing connection because of timeout in state 'close_sent' likely due to lack of client action.
unknown command {request,101,sasl_handshake}, sending close command.
Ignored unknown message emit_stats in state close_sent
Closing connection because of timeout in state 'close_sent' likely due to lack of client action.
I'm missing something.
@simone-fariselli Make sure to use 3.13 (alpha or RC). There's a test in the stream Java client suite.
The server PR that adds support to update a secret in a stream connection is in 3.13: https://github.com/rabbitmq/rabbitmq-server/pull/9187.
Note the token update should be done transparently in the background. Getting a new token (by calling a specific CredentialsProvider
implementation) and updating the token should be decoupled. The design of the AMQP .NET client should be appropriate for the stream client library as well.
Discussed in https://github.com/rabbitmq/rabbitmq-stream-dotnet-client/discussions/334