confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
90 stars 869 forks source link

Crashes withot logs when using oauth #2158

Open Cheshirre opened 11 months ago

Cheshirre commented 11 months ago

Description

Crashes without logs when using authorization type "OAUTHBEARER".

client.OAuthBearerSetToken(token.TokenValue, token.Expiration, **null**);

OS -> Ubuntu Linux, MacOS, etc. Nuget package: Confluent.Kafka, Version=2.3.0.0

How to reproduce

Reproduces on unix OS family: local or in docker container. Works on windows.

Set principal to null in client.OAuthBearerSetToken(token.TokenValue, token.Expiration, **null**): https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/test/Confluent.Kafka.IntegrationTests/Tests/OauthBearerToken_PublishConsume.cs

Works, when principal set to empty string.

Checklist

Please provide the following information:

anchitj commented 9 months ago

Can you provide debug logs?

Cheshirre commented 9 months ago

Can you provide debug logs?

There are no logs becouse this issue https://github.com/confluentinc/confluent-kafka-dotnet/issues/1834

fabianpersson commented 6 months ago

Still an issue. I am unable to provide any logs, since it crashes with exit code 139 (memory violation issue) OS: Windows 10 (on WSL)/Confluent.Kafka v2.4.0

I was able to get it work with just an empty string however

shlomiassaf commented 5 months ago

Happens to me as well OSX with latest nuget

If principal is set to null it will exit with CODE 139 in with or without a debug session. If principal is set to an empty string, all is ok.

ublink commented 4 months ago

This is also happening in docker env for me. Works fine outside of docker.


    .SetOAuthBearerTokenRefreshHandler(async (c, p) =>
    {
      try
           {
             var token = await _tokenService.GetTokenAsync();
             if (token != null && !string.IsNullOrEmpty(token.AccessToken))
             {
                var tokenExpiration = DateTimeOffset.UtcNow.AddMinutes(15).ToUnixTimeMilliseconds();
                c.OAuthBearerSetToken(token.AccessToken, tokenExpiration, null);
             }
            else
            {
              c.OAuthBearerSetTokenFailure("Token is null or empty");
            }
          }
          catch (Exception ex)
          {
            _logger.LogError(ex.Message);
            c.OAuthBearerSetTokenFailure($"Token retrieval failed: {ex.Message}");
           }
 });