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

Calling WebSocketClient Start() or StartOrFail() takes > 2 seconds? #100

Closed
LukeSawyers opened this issue Dec 10, 2021 · 2 comments
Closed

Comments

@LukeSawyers
Copy link

Hi I'm experiencing some slower-than-Id-expect behavior when starting up the WebsocketClient class
Using Setup:

_webSocket = new WebsocketClient(
    uri, () => new ClientWebSocket { Options = { KeepAliveInterval = TimeSpan.FromMilliseconds(50) } }
)
{
    IsReconnectionEnabled = true,
    ReconnectTimeout = TimeSpan.FromMilliseconds(100),
    ErrorReconnectTimeout = TimeSpan.FromMilliseconds(100)
};

And calling connecting code

public async Task ConnectAsync()
{
    try
    {
        var sw = Stopwatch.StartNew();
        await _webSocket.StartOrFail();
        sw.Stop();
    }
    catch (Exception ex)
    {
        _logger.Warn($"Error in {nameof(ConnectAsync)}", ex);
    }
}

sw.Elapsed will show ~2 sec depending on exact environment, that seems a little long, is there some way of reducing this / am I doing something wrong?

@LukeSawyers
Copy link
Author

On testing with other socket clients, this seems to be more to do with the server side, please ignore this

@PhantomGamers
Copy link

Were the other socket clients you tested also based on ClientWebSocket ?

I'm currently running into this same issue, whereas in C++ with boost it connects significantly faster.

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

2 participants