question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AvroSerializer/SchemaRegistry works on .NET Core but not .NET Framework 4.5.2

See original GitHub issue

Description

I have following the sample code (https://github.com/confluentinc/confluent-kafka-dotnet/tree/master/examples/AvroSpecific) to build a Kafka Avro Producer with C# code. But it works perfectly on .NET Core project, but failed on .NET Framework 4.5.2. Failed reason is key and value serialization error.

How to reproduce

Build and Run the code provided below on Visual Studio 2015 Target Framework 4.5.2

Checklist

Please provide the following information:

  • A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.

public class Program { public static void Main(string[] args) { try { string bootstrapServer = “myBootstrapServer”; string topicName = “myTopicName”; string schemaRegistryUrl = “myUrl”; var saslUsername = “username”; var saslPassword=“password”; var sslCaLocation = “sslCaLocation”

            var config = new ProducerConfig
            {
                BootstrapServers = bootstrapServer,
                SecurityProtocol = SecurityProtocol.SaslSsl,
                SaslMechanism = SaslMechanism.ScramSha512,
                SaslUsername = saslUsername,
                SaslPassword = saslPassword,
                SslCaLocation = sslCaLocation,
            };

            var schemaRegistryConfig = new SchemaRegistryConfig
            {
                SchemaRegistryUrl = schemaRegistryUrl,
                SchemaRegistryBasicAuthCredentialsSource = AuthCredentialsSource.UserInfo,
                SchemaRegistryBasicAuthUserInfo = saslUsername + ":" + saslPassword,
                SchemaRegistryRequestTimeoutMs = 5000,
                SchemaRegistryMaxCachedSchemas = 10
            };

            using (var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig))
            using (var producer =
                    new ProducerBuilder<string, RepublishRequest>(config)
                        .SetKeySerializer(new AvroSerializer<string>(schemaRegistry))
                        .SetValueSerializer(new AvroSerializer<RepublishRequest>(schemaRegistry))
                        .Build())
            {
                RepublishRequest request = new RepublishRequest { EntityType = EntityType.RMSSKU,
                    EntityId = "53486682",
                    Market = Market.US,
                    SellingChannel = SellingChannel.RACK,
                    ApplicationId = "TestApp"
                };

                byte[] val = SerializerAvro.Serialize(request);
                var task = producer.ProduceAsync(topicName, new Message<string, RepublishRequest> { Key = "test", Value = request });
                task.Wait();

                if (task.IsFaulted) {
                    Console.Write($"error producing message: {task.Exception.Message}");
                } else {
                    Console.Write($"produced to: {task.Result.TopicPartitionOffset}");
                }
                producer.Flush(TimeSpan.FromSeconds(10));
            }
        } catch (Exception e) {
            Console.Write($"EXCEPTION: {e}");
        }
    }

}

RepublishRequest is auto generated Avro class.

  • Confluent.Kafka nuget version. 1.0.0

  • Apache Kafka version.

  • Client configuration.

  • Operating system. Windows 10

  • Provide logs (with “debug” : “…” as necessary in configuration).

  • Provide broker log excerpts.

EXCEPTION: System.AggregateException: One or more errors occurred. —> Confluent.Kafka.ProduceException2[System.String,com.nordstrom.rms.republish.RepublishRequest]: Local: Key serialization error ---> System.Net.Http.HttpRequestException: [https://schema-registry.nonprod.us-west-2.aws.proton.nordstrom.com/] HttpRequestException: An error occurred while sending the request. at Confluent.SchemaRegistry.RestService.<ExecuteOnOneInstanceAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.RestService.<RequestAsync>d__61.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.RestService.<RegisterSchemaAsync>d__14.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.CachedSchemaRegistryClient.<RegisterSchemaAsync>d__13.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.Serdes.SpecificSerializerImpl1.<Serialize>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.Serdes.AvroSerializer1.<SerializeAsync>d__6.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Confluent.Kafka.Producer2.<ProduceAsync>d__51.MoveNext() --- End of inner exception stack trace --- at Confluent.Kafka.Producer2.<ProduceAsync>d__51.MoveNext() — End of inner exception stack trace — at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Confluent.Kafka.Examples.SimpleProducer.Program.Main(String[] args) in C:\MyWork\TestApplication\SimpleKafkaProducer\Program.cs:line 79 —> (Inner Exception #0) Confluent.Kafka.ProduceException2[System.String,com.nordstrom.rms.republish.RepublishRequest]: Local: Key serialization error ---> System.Net.Http.HttpRequestException: [https://schema-registry.nonprod.us-west-2.aws.proton.nordstrom.com/] HttpRequestException: An error occurred while sending the request. at Confluent.SchemaRegistry.RestService.<ExecuteOnOneInstanceAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.RestService.<RequestAsync>d__61.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.RestService.<RegisterSchemaAsync>d__14.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.CachedSchemaRegistryClient.<RegisterSchemaAsync>d__13.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.Serdes.SpecificSerializerImpl1.<Serialize>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Confluent.SchemaRegistry.Serdes.AvroSerializer1.<SerializeAsync>d__6.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Confluent.Kafka.Producer2.<ProduceAsync>d__51.MoveNext() --- End of inner exception stack trace --- at Confluent.Kafka.Producer2.<ProduceAsync>d__51.MoveNext()<— Enter to exit

  • Critical issue.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mhowlettcommented, May 20, 2020

marking as enhancement since I think we probably want to surface a different top level exception (that derives from ProduceException) for various common problems with SR integration.

1reaction
timarapecommented, May 16, 2020

@confluentinc it was actually the certs that had issues in my case, its now resolved. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I add .NET framework 4.5.2 to Asp.Net Core
1 Answer 1 ... There are two versions of .NET Core, .NET Standard version (Portable version, which you use in your project) and...
Read more >
Runtime changes for migration to .NET Framework 4.5.x
This issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework....
Read more >
Microsoft .NET Framework 4.5.2 (Offline Installer)
This package is larger than the web installer and does not include the language packs. You can download and install the language packs...
Read more >
Troubleshoot blocked .NET Framework installations and ...
Troubleshoot issues you encounter that prevent installation of the .NET Framework. Consult status messages for information to resolve ...
Read more >
.NET Framework 4.5.2, 4.6, 4.6.1 will reach End of Support ...
NET Framework 4.5.2, 4.6, and 4.6.1 will reach end of support* on April 26, 2022. After this date, we will no longer provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found