unknow socket error from asp.net core web api

Mutturaj Bali 1 Reputation point

this app is running ecs fargate containers with .net6.0 and getting following error intermittently once in 10requests while connecting mysql database which is in aws rds.
---> System.Net.Sockets.SocketException (0xFFFDFFFE): Unknown socket error
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
--- End of stack trace from previous location ---
at System.Net.Sockets.TcpClient.CompleteConnectAsync(Task task)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings, MyNetworkStream& networkStream)
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at app.dbhelper.DBManagerMysql.GetConnection(Boolean open, MySqlConnectionStringBuilder alternate)

A set of technologies in the .NET Framework for building web applications and XML web services.
4,237 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,376 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Takahito Iwasa 4,841 Reputation points MVP

    Hi. @Mutturaj Bali

    Is it possible to isolate the problem?

    • Does the problem occur with .NET2.2 on ECS?
    • Does the problem occur with .NET6 on EC2?
    • Does the problem occur with ".NET6 on ECS" to "MySQL on EC2"?

    If you're communicating privately with RDS in an AWS VPC, private subnets are less of an issue in my experience.
    If the ECS needs to communicate externally or communicate with other public AWS services and is canceled, you may configure a VPC endpoint, but it's a good idea to start with the above isolation.

    0 comments No comments