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.

The WriteAsync method cannot be called when another write operation is pending.

See original GitHub issue

Hello,

We started dropping bedrock into our server application and have been getting this:

[20:53:31 ERR] AuthWorker Error processing queue System.AggregateException: One or more errors occurred. ( The WriteAsync method cannot be called when another write operation is pending.) ---> System.NotSupportedException: The WriteAsync method cannot be called when another write operation is pending. at System.Net.Security.SslStream.WriteAsyncInternal[TWriteAdapter](TWriteAdapter writeAdapter, ReadOnlyMemory1 buffer) at System.IO.Pipelines.StreamPipeWriter.FlushAsyncInternal(CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at ArchonPolicyServer.Server.Connections.BedrockConnection.SendAsync(Byte[] msg)

Is there anything we may be doing wrong that may allow us to work around this issue?

We’re using https://github.com/redhat-developer/kestrel-linux-transport along with it as the server runs on .NET Core 3 in linux.

Appreciate any insights you may have.

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
fuhrycommented, Dec 18, 2019

We suspect it’s within SslStream. We tried doing .WriteAsync().Wait() with a lock around it just to see if it was something in our own code, and observed no change in behavior (besides everything slowing greatly of course). The test client I’m using to produce this behavior also works in a half-duplex fashion, never sending a message before receiving a response to the previous message, and our server is sending msgpack structures all in a single write call. Theoretically this should mean that even unsafe code on the server should never trigger an unsafe write, but here we are.

I’ll find some time today or tomorrow to get a minimal reproducer working.

0reactions
davidfowlcommented, Dec 18, 2019

@fuhry That’s the direction I’d like to go with it. Create an ecosystem of reader and writers that can be used to compose higher level protocols or build your own parsers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SslStream.WriteAsync "The BeginWrite method cannot be ...
SslStream.WriteAsync "The BeginWrite method cannot be called when another write operation is pending" ... Could you post your code? I think that ...
Read more >
.net core 2.1 The WriteAsync method cannot be called ...
NotSupportedException : The WriteAsync method cannot be called when another write operation is pending. at System.Net.Securit...
Read more >
SslStream.WriteAsync “The BeginWrite method cannot be ...
How to prevent this issue when writing data to the client Asynchronously The BeginWrite method cannot be called when another write operation is...
Read more >
SslStream.WriteAsync Method (System.Net.Security)
A task that represents the asynchronous write operation. ... You cannot call this method until you have successfully authenticated.
Read more >
The connection with node C was suddenly broken.
System.NotSupportedException : The WriteAsync method cannot be called when another write operation is pending. at System.Net.Security.SslStreamInternal.
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