Specify timeout for websocket connection

I'm using Marfusios' websocket-client and I'm trying to specify a timeout period for establishing the connection, but I'm unsure how, or if it's even possible.

The GitHub demonstrates creating a factory for some client settings, but there are no options for specifying a timeout period
c#
// Param: Func<ClientWebSocket>? clientFactory

var factory = new Func<ClientWebSocket>(() => new ClientWebSocket
{
    Options =
    {
        KeepAliveInterval = TimeSpan.FromSeconds(5),
        Proxy = ...
        ClientCertificates = ...
    }
});
var client = new WebsocketClient(url, factory);


One client constructor gives the option for a connectionFactory, where a cancelation token can be provided, but I'm unure how to use it (I'm still pretty fresh to C#):
c#
Func<Uri, CancellationToken, Task<WebSocket>>? connectionFactory
Was this page helpful?