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.

Too many TCP connections established

See original GitHub issue

When I conduct the concurrent test of Minio, I find that if I upload files concurrently, a lot of TCP connections will be established and will not be released。 My test code is as follows: ` static void Main(string[] args) {

        try
        {
            Run().Wait();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        Console.ReadLine();
    }

    private static async Task Run()
    {
        // Make a new bucket called mymusic.
        var bucketName = "testsize"; //<==== change this
        var location = "us-east-1";
        var filePath = @"C:\Users\admin\Desktop\c143a9bc-be71-4475-9981-3c0d8f60d7f5";
        var contentType = "application/octet-stream";
        var endpoint = "192.168.1.14:9000";
        var accessKey = "minioadmin";
        var secretKey = "minioadmin";
        try
        {
            //FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
          
            var minio = new MinioClient(endpoint, accessKey, secretKey);

            bool found = await minio.BucketExistsAsync(bucketName);
            if (!found)
            {
                await minio.MakeBucketAsync(bucketName, location);
            }

            Console.WriteLine("10万个文件上传开始~~~~" + DateTime.Now);
            Stopwatch stopwatch = Stopwatch.StartNew();
            await Task.WhenAll(Enumerable.Range(0, 100_000)
            .Select(_ => Task.Run(async () =>
            {
                //fileStream.Position = 0;
                await minio.PutObjectAsync(bucketName, Guid.NewGuid().ToString("N"), filePath, contentType);
            }))).ConfigureAwait(false);
            stopwatch.Stop();

            Console.WriteLine("10万个文件上传结束~~~~" + DateTime.Now);
            Console.WriteLine("总共用时" + stopwatch.ElapsedMilliseconds / 1000 / 60 + "分钟");
            //fileStream.Dispose();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }

` At this time, I run the test code and view the TCP link through the tcpview tool。 Found that the TCP connection has been established and has not been released。At this time, the CPU of my local computer has gone up to 100%。 image

By looking at the source code, it is found that when communicating, the application is made by csharprest, and a method that has been abandoned is used. I don’t know if this is the reason。 the code like this private async Task<IRestResponse> ExecuteTaskCoreAsync(IEnumerable<ApiResponseErrorHandlingDelegate> errorHandlers, IRestRequest request, CancellationToken cancellationToken = default(CancellationToken)) { ... //It's abandoned IRestResponse response = await this.restClient.ExecuteTaskAsync(request, cancellationToken).ConfigureAwait(false); ... }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
harshavardhanacommented, Feb 16, 2022

Fixed by #551 … and by #582

0reactions
yilezhucommented, May 12, 2020

Hi @harshavardhana ,I tested the RestSharp components separately, and found that the problem of TCP leakage was caused by the HTTP component used. I tried to submit an issue to the official, hoping to solve it! https://github.com/restsharp/RestSharp/issues/1461

Read more comments on GitHub >

github_iconTop Results From Across the Web

Too many established connections left open
Hypothesis 1: your application is behind a firewall that drops idle tcp-connections after a given amount of time.
Read more >
A command displays too many TCP/IP connections
Running the NETSTAT -A command from the command prompt shows a large number of TCP/IP connections established by the ipMonitor software.
Read more >
Way Too Many Active Connections - General Security
If TCPView indicates a number of connections, some of them can be explained by applications that run in the background which are attempting...
Read more >
netstat shows too many established connections in windows
I just called the customer service of my ISP and they ordered me to do netstat -n -o , then I found too...
Read more >
linux - Too many persistent TCP connections
I think the keepalive parameters work for connections in TIMED_WAIT state only, but the connections stay ESTABLISHED. It seems that the server ...
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