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.

System.IO.IOException: Unable to write data to the transport connection: Broken pipe.

See original GitHub issue

When running a .NET Core 2.1 app in Docker, after a few minutes, the app exits with the following exception:

identity-api         |    Unhandled Exception: System.AggregateException: One or more errors occurred. (Unable to write data to the transport connection: Broken pipe.) ---> System.IO.IOException: Unable to write data to the transport connection: Broken pipe. ---> System.Net.Sockets.SocketException: Broken pipe
identity-api         |    at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
identity-api         |    --- End of inner exception stack trace ---
identity-api         |    at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
identity-api         |    at System.Data.SqlClient.SNI.SslOverTdsStream.WriteInternal(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token, Boolean async)
identity-api         |    --- End of inner exception stack trace ---
identity-api         |    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
identity-api         |    at System.Threading.Tasks.Task.Wait()
identity-api         |    at System.Data.SqlClient.SNI.SslOverTdsStream.Write(Byte[] buffer, Int32 offset, Int32 count)
identity-api         |    at System.Net.Security.SslStreamInternal.WriteSingleChunk[TWriteAdapter](TWriteAdapter writeAdapter, ReadOnlyMemory`1 buffer)
identity-api         |    at System.Net.Security.SslStreamInternal.WriteAsyncInternal[TWriteAdapter](TWriteAdapter writeAdapter, ReadOnlyMemory`1 buffer)
identity-api         |    at System.Net.Security.SslStreamInternal.Write(Byte[] buffer, Int32 offset, Int32 count)
identity-api         |    at System.Net.Security.SslStream.Write(Byte[] buffer, Int32 offset, Int32 count)
identity-api         |    at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet)
identity-api         |    at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet)
identity-api         |    at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags)
identity-api         |    at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose()
identity-api         |    at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose()
identity-api         |    at System.Data.SqlClient.TdsParserSessionPool.Dispose()
identity-api         |    at System.Data.SqlClient.TdsParser.Disconnect()
identity-api         |    at System.Data.SqlClient.SqlInternalConnectionTds.Dispose()
identity-api         |    at System.Data.ProviderBase.DbConnectionPool.DestroyObject(DbConnectionInternal obj)
identity-api         |    at System.Data.ProviderBase.DbConnectionPool.CleanupCallback(Object state)
identity-api         |    at System.Threading.TimerQueueTimer.CallCallback()
identity-api         |    at System.Threading.TimerQueueTimer.Fire()
identity-api         |    at System.Threading.TimerQueue.FireNextTimers()

There are two containers that access SQL, they both exit around the same time.

This happens consistently. I’ve tried Alpine and non-Alpine images. The apps are both MVC and the DataContexts have been unused other than running the migrations.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:54 (16 by maintainers)

github_iconTop GitHub Comments

6reactions
johnsimonscommented, Jul 17, 2019

Getting the same error running the following:

Netcoreapp2.2 / Linux container (mcr.microsoft.com/dotnet/core/runtime:2.2) / Kubernetes 0.13.5 / SQL Azure ( Elastic Pools, Standard Plan )

Unhandled Exception: System.AggregateException: One or more errors occurred. (Unable to write data to the transport connection: Broken pipe.) ---> System.IO.IOException: Unable to write data to the transport connection: Broken pipe. ---> System.Net.Sockets.SocketException: Broken pipe
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Data.SqlClient.SNI.SslOverTdsStream.WriteInternal(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token, Boolean async)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Data.SqlClient.SNI.SslOverTdsStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security.SslStreamInternal.WriteSingleChunk[TWriteAdapter](TWriteAdapter writeAdapter, ReadOnlyMemory`1 buffer)
   at System.Net.Security.SslStreamInternal.WriteAsyncInternal[TWriteAdapter](TWriteAdapter writeAdapter, ReadOnlyMemory`1 buffer)
   at System.Net.Security.SslStreamInternal.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security.SslStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet)
   at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet)
   at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags)
   at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose()
   at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose()
   at System.Data.SqlClient.TdsParserSessionPool.Dispose()
   at System.Data.SqlClient.TdsParser.Disconnect()
   at System.Data.SqlClient.SqlInternalConnectionTds.Dispose()
   at System.Data.ProviderBase.DbConnectionPool.DestroyObject(DbConnectionInternal obj)
   at System.Data.ProviderBase.DbConnectionPool.CleanupCallback(Object state)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()

This causes the pods to restart with a 139 exit code, and we can’t prevent it 😞

Currently, this is a show stopper for us, are there any workarounds?

4reactions
David-Engelcommented, Aug 5, 2019

I noticed a very suspicious throw introduced long ago that would easily cause this issue if disposing a broken, mars-enabled connection: https://github.com/dotnet/corefx/pull/4594/files#diff-a8e6146000f306b97ce4e48207f7cd9fR69 I plan to remove the throw for the next M.D.SqlClient preview.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to write data to the transport connection: Broken pipe
"Broken pipe" means you attempt to write using a connection that have been closed by the other end. – Some programmer dude. Jul...
Read more >
IOException: Unable to write data to the transport connection
IO.IOException: Unable to write data to the transport connection: Broken pipe. dotnet/runtime/79976. github.com. System.IO.
Read more >
Unable to write data to the transport connection
Too large data model may be a reason for your scenario, maybe you can try to cut down you data size and try...
Read more >
Unit tests throws Unable to write data to the transport ...
System.IO.IOException: Unable to write data to the transport connection: An established connection was aborted by the software in your host ...
Read more >
BrokenPipe error. Mp3 Files only. : r/Readarr
System.IO.IOException: Unable to write data to the transport connection: Broken pipe. ... SocketException (32): Broken pipe at System.Net.
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