Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Connection Times? #322

Open
LukeSawyers opened this issue Dec 11, 2021 · 0 comments
Open

Slow Connection Times? #322

LukeSawyers opened this issue Dec 11, 2021 · 0 comments

Comments

@LukeSawyers
Copy link

LukeSawyers commented Dec 11, 2021

Consistently experiencing rather long connection times from various clients (~ 2 sec) when using the fleck server
Given Server code:

var s = new WebSocketServer("ws://0.0.0.0:8049")
s.ListenerSocket.NoDelay = true;
s.Start(HandleSocketConnection);

Where HandleSocketConnection can be an empty method, doesn't appear to make much of a difference
And a variety of client implementations:

using var fleckServer = CreateServer();

var sw = Stopwatch.StartNew();
var client = await CreateClient();
_logger.Info($"Net Client Connect time {sw.ElapsedMilliseconds}ms");
sw.Restart();
var socket = new WebSocketSharp.WebSocket(RootUrl + Endpoint1);
socket.Connect();
_logger.Info($"Socket sharp connect time {sw.ElapsedMilliseconds}ms");
sw.Restart();
await new ClientWebSocket().ConnectAsync(new Uri(RootUrl + Endpoint1), CancellationToken.None);
_logger.Info($"Client Web Socket connect time {sw.ElapsedMilliseconds}ms");

Output shows some quite long connection times

Debug: Socket open to /endpoint1 from 127.0.0.1:63778 
Info: Websocket Reconnected : Initial 
Info: Net Client Connect time 3105ms 
Debug: Socket open to /endpoint1 from 127.0.0.1:63781 
Info: Socket sharp connect time 2035ms 
Debug: Socket open to /endpoint1 from 127.0.0.1:63782 
Info: Client Web Socket connect time 2043ms 
Info: Websocket Disconnected : ByServer NormalClosure

Running on .NET 5.0 and 6.0 with similar results

Normally under the same circumstances I'd expect to see < 100 ms. These times seem a bit too slow. Is there something I'm missing / can this be replicated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant