WampSharp icon indicating copy to clipboard operation
WampSharp copied to clipboard

Socket limit reached - server doesn't recover

Open dwlodarz opened this issue 7 years ago • 8 comments

I have implemented a router and a client in .net just to see how it works in general. Then I have deployed it to S2 AppService in Azure. The problem that I experience is that once the TCP connection limit is reached (~4k) and I close all the clients the router becomes unusable. I cannot connect any new clients. It seems that the connections are not being disposed.

This is the exception I'm getting: System.AggregateException: One or more errors occurred. (Unable to connect to the remote server) ---> System.Net.WebSockets.WebSocketException: Unable to connect to the remote server ---> System.Net.Http.HttpRequestException: Nie mozna przeprowadzic operacji na gniezdzie, poniewaz w systemie brakuje miejsca na bufor lub poniewaz zostala zapelniona kolejka ---> System.Net.Sockets.SocketException: Nie mozna przeprowadzic operacji na gniezdzie, poniewaz w systemie brakuje miejsca na bufor lub poniewaz zostala zapelniona kolejka at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)

which means pretty much this: " An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full"

Could you pls advise?

dwlodarz avatar Oct 29 '18 15:10 dwlodarz

If you can write a local simple repro (i.e. does not involve Azure), then I might be able to investigate this. @bigbearzhu do you guys run on Azure? Did you try these kind of things?

Elad

darkl avatar Oct 29 '18 15:10 darkl

When it comes to router it's nothing more but Startup.cs-> app.Map("", builder => { builder.UseWebSockets(new WebSocketOptions()); wampHost.RegisterTransport(new DssConnectorWebSocketTransport(builder, log), new JTokenJsonBinding(), new JTokenMsgpackBinding()); }); wampHost.Open();

Program.cs-> WebHost.CreateDefaultBuilder(args) .UseUrls("http://localhost:5000", "http://localhost:80", "https://localhost:443") .UseStartup<Startup>() .UseSetting("detailedErrors", "true") .CaptureStartupErrors(true) .Build().Run(); and dependencies: image

dwlodarz avatar Oct 30 '18 08:10 dwlodarz

What is DssConnectorWebSocketTransport? Please add a full repro. Preferably, upload it to https://gist.github.com.

Elad

darkl avatar Oct 30 '18 11:10 darkl

Oh sorry. The class you mentioned is just AspNetCoreWebSocketTransport with some logging added around opening the connection. No additional logic or changes. I cant give you the full src code unfortuantely. But everuthing relevant is here

dwlodarz avatar Oct 30 '18 11:10 dwlodarz

Can't reproduce. Here's an attempt. Client eventually crashes with System.Net.Sockets.SocketException (10055): An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. Afterwards, restarting client (without touching the server), new clients are able to connect.

Elad

darkl avatar Nov 02 '18 20:11 darkl

In turns out that this is an issue with IIS/IIS Express, see here. See also #279.

darkl avatar Nov 15 '18 03:11 darkl

@darkl , is this resolved as we are still facing the same issue.

narenkv avatar Aug 08 '19 08:08 narenkv

You'll have to wait several minutes for the server to detect the disconnected clients, see this comment.

darkl avatar Aug 08 '19 09:08 darkl