1iveowl/WebsocketClientLite.PCL

CreateObservableMessageReceiver TimeOut

alberk8 opened this issue · 1 comments

How do I can reduce the timeout period if the websocket service is down (the whole site gone AWOL) ?

Or is it possible to introduce a Cancellation Token ?

Currently it would take around more than 20 seconds for it it to error out and the await statement is blocking.

var messageObserver = await websocketClient.CreateObservableMessageReceiver(
                new Uri("wss://myweb.com/ws:443"),
                ignoreServerCertificateErrors: true,
                headers: headers,
                subProtocols: subprotocols,
                tlsProtocolType: TlsProtocolVersion.Tls12);

I've added CancellationToken option.

Could you test NuGet v4.2.5-beta1 and let me know if this does the trick?

You can see the changes to the code in the develop brach.

You can now do this:

var createTokenSource = new CancellationTokenSource();

var messageObserver = await websocketClient.CreateObservableMessageReceiver(
                new Uri("wss://echo.websocket.org"),
                ignoreServerCertificateErrors: true,
                headers: headers,
                subProtocols: subprotocols,
                tlsProtocolType: TlsProtocolVersion.Tls12, 
                token: createTokenSource.Token);