NotSupportedException when publishing message
See original GitHub issueRepro:
Not really a repro possible. We have published millions of messages through nats.net and never encountered this issue. However, for a single published message we logged a NotSupportedException. I will see if I can find out more, but given that this is virtually impossible to reproduce I can’t do much more than staring at the code.
Expected:
Publishing a message through nats.net should not throw a NotSupportedException
Actual:
A NotSupportedException (apparently trying to seek a NetworkStream) is thrown for a single message (all other messages are published properly).
Here is the stack trace:
System.NotSupportedException: Stream does not support seeking.
at System.IO.BufferedStream.EnsureCanSeek()
at System.IO.BufferedStream.get_Position()
at NATS.Client.Connection.publish(String subject, String reply, Byte[] data, Int32 offset, Int32 count, Boolean flushBuffer)
at NATS.Client.Connection.Publish(String subject, String reply, Byte[] data)
at My.Namespace.Infrastructure.Nats.Nats.PublishData(IPublishable dataToSend, String subject, String reply, Boolean flushImmediately) in W:\\_work\\269\\s\\My.Namespace.Infrastructure\\Nats\\Nats.cs:line 70
at My.Namespace.Infrastructure.Nats.Nats.PublishData(IPublishable dataToSend, String subject, Boolean flushImmediately) in W:\\_work\\269\\s\\My.Namespace.Infrastructure\\Nats\\Nats.cs:line 32
at My.Namespace.CalculationService.Sequence.SequenceProducer.HandleOnCalculationResult(Object sender, CalculationResultEventArgs args) in W:\\_work\\269\\s\\My.Namespace.CalculationService\\Sequence\\SequenceProducer.cs:line 542
at My.Namespace.Calculation.Core.SequenceConsumer.ConsumeSequence() in W:\\_work\\269\\s\\My.Namespace.Calculation.Core\\SequenceConsumer.cs:line 163
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
at My.Namespace.Calculation.Core.SequenceConsumer.StartConsumeAsync() in W:\\_work\\269\\s\\My.Namespace.Calculation.Core\\SequenceConsumer.cs:line 136
Environment
- dotnet core 3.1
- nats.net v. 0.10 81aaa2211
- OS: Windows Docker (Server Core 2019) on Windows Server 2019 Datacenter host
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (9 by maintainers)
Top Results From Across the Web
C#: should I throw an ArgumentException or ...
According to MSDN: NotSupportedException The exception that is thrown when an invoked method is not supported, or when there is an attempt ...
Read more >NotSupportedException - C# in a Nutshell [Book]
This exception indicates an attempt to use an unsupported method. For example, if you try to seek on a stream that is based...
Read more >adding documents is not supported - Developer Community
I am using v16.11 and have even tried the 2022 version. I cannot refactor the class PlayerInput without getting this error. image.png. Visual ......
Read more >System.NotSupportedException in unity 2019 only in Build ...
I can't publish my game with this issue. My game is like a trash and totally waste of time if this issue can't...
Read more >System.NotSupportedException: Operation is not supported.
Hi, i have an application that translates EventStore streams to database views that suddenly stopped working. Here are the logs that i gather...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great, I’ll deploy it on one of our environments tomorrow. We’ll have decent load over the weekend, but I don’t expect anything anything to break. 😃
I’ve built a pre-release containing this fix here: https://www.nuget.org/packages/NATS.Client/0.11.0-pre1
If you could let me know if you run into the issue again, that’d be great. The only difference between v 0.10.1 and the prerelease is this PR, so it’s low risk to use/test in production. There are some other things I’d like to add before the next release.