nats.net
nats.net copied to clipboard
Can't serialize System.Object
Observed behavior
Everything is normal when I use the console, but there is an error when using AddNats
services.AddNats(configureOpts: opt => opt with
{
Url = "nats://localhost:4223"
});
Expected behavior
serialization
Server and client version
2.12.0
Host environment
No response
Steps to reproduce
services.AddNats(configureOpts: opt => opt with
{
Url = "nats://localhost:4223"
});
await foreach (NatsMsg<object?> msg in nc.SubscribeAsync<object?>("foo.*.*"))
{
Console.WriteLine($"Received {msg.Subject}: {msg.Data}\n");
}
await nc.PublishAsync("foo.0.0", new { Test = TestEnum.None });
It should work if you use AddNatsClient() extension rather. there are two DI packages, one is geared towards AOT so it won't serialize ad hoc JSON by default.