title: What is Local value serialization error in kafka?
body: <p>I recently went through Confluent Kafka library in C# .net 4.7.2 framework version. But, many times I faced Local Value serialization error. Is this error is a generic one? or this error tells anything specifically? I'm not sure when will this error raises?</p>
  
  <pre><code>var rs = (RecordSchema)RecordSchema.Parse(@"{
  ""namespace"": ""Confluent.Kafka.Examples.AvroSpecific"",
  ""type"": ""record"",
  ""name"": ""ProduceConsumeUser2"",
  ""fields"": [
      {""name"": ""name"", ""type"": ""string""},
      {""name"": ""favorite_number"",  ""type"": [""int"", ""null""]},
      {""name"": ""favorite_color"", ""type"": [""string"", ""null""]}
  ]}");
  
     using (var schemaRegistry = new CachedSchemaRegistryClient(schemaRegistryConfig)){
     using (var genericProducer = new ProducerBuilder&lt;string, GenericRecord&gt;(producerConfig)
    .SetValueSerializer(new AvroSerializer&lt;GenericRecord&gt;(schemaRegistry).AsSyncOverAsync())
    .Build())
  {
      var genericRecord = new GenericRecord(rs);
      genericRecord.Add("name", "my name 2");
      genericRecord.Add("favorite_number", 44);
      genericRecord.Add("favorite_color", null);
  
      var message = new Message&lt;string, GenericRecord&gt;
      {
          Key = contentEventName,
          Value = genericRecord
      };
      Task.Run(() =&gt; genericProducer.ProduceAsync(contentEventName, message)).ConfigureAwait(false).GetAwaiter().GetResult();
  }}
  </code></pre>
  
  <p>Error we get:</p>
  
  <pre><code> "Error":{
    "Code":-161,
    "IsFatal":false,
    "Reason":"Local: Value serialization error",
    "IsError":true,
    "IsLocalError":true,
    "IsBrokerError":false
  },
  "Message":"Local: Value serialization error",
  "Data":{ },
  "InnerException":{
    "ClassName":"System.Threading.Tasks.TaskCanceledException",
    "Message":"A task was canceled.",
    "Data":null,
    "InnerException":null,
    "HelpURL":null,
    "StackTraceString":"   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Confluent.SchemaRegistry.RestService.&lt;ExecuteOnOneInstanceAsync&gt;d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Confluent.SchemaRegistry.RestService.&lt;RequestAsync&gt;d__10`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Confluent.SchemaRegistry.RestService.&lt;RegisterSchemaAsync&gt;d__18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Confluent.SchemaRegistry.CachedSchemaRegistryClient.&lt;RegisterSchemaAsync&gt;d__21.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Confluent.SchemaRegistry.Serdes.GenericSerializerImpl.&lt;Serialize&gt;d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Confluent.SchemaRegistry.Serdes.AvroSerializer`1.&lt;SerializeAsync&gt;d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n   at Confluent.Kafka.Producer`2.&lt;ProduceAsync&gt;d__52.MoveNext()",
    "RemoteStackTraceString":null,
    "RemoteStackIndex":0,
    "ExceptionMethod":"8\nThrowForNonSuccess\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Runtime.CompilerServices.TaskAwaiter\nVoid ThrowForNonSuccess(System.Threading.Tasks.Task)",
    "HResult":-2146233029,
    "Source":"mscorlib",
    "WatsonBuckets":null
  },
  "StackTrace":"   at Confluent.Kafka.Producer`2.&lt;ProduceAsync&gt;d__52.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n  at LogEvent(String contentEventName, IDictionary`2 e, RecordSchemaName re)",
  "HelpLink":null,
  "Source":"Confluent.Kafka",
  "HResult":-2146233088
  </code></pre>