dougdellolio / coinbasepro-csharp

The unofficial .NET/C# client library for the Coinbase Pro/GDAX API
MIT License
192 stars 90 forks source link

Websocket and Authentication #275

Closed cmorgado closed 3 years ago

cmorgado commented 3 years ago

Hi reading the documentation I'm doing ` public CoinbaseClient() {

        var coinbaseProClient = new CoinbaseProClient();
        _websocket = coinbaseProClient.WebSocket;

        _websocket.OnHeartbeatReceived += WebSocketOnOnHeartbeatReceived;
        _websocket.OnTickerReceived += WebSocketOnOnTickerReceived;
    }

    public void AddTicker(ProductType productType)
    {
        _productTypes.Add(productType);
        if (_websocket.State==WebSocketState.Open)
            _websocket.Stop();

        _websocket.Start(_productTypes, new List<ChannelType>() { ChannelType.Full, ChannelType.User });
    }

`

But I get an error on blazor: Unhandled exception rendering component: System.Security.Cryptography.X509Certificates is not supported on this platform. System.PlatformNotSupportedException: System.Security.Cryptography.X509Certificates is not supported on this platform.

Being that I'm using the anonymous socket is there a workaround?

dougdellolio commented 3 years ago

hey @cmorgado, just did some digging and found this related to blazor: https://docs.microsoft.com/en-us/dotnet/core/compatibility/cryptography/5.0/cryptography-apis-not-supported-on-blazor-webassembly. Are you seeing any warnings about it? Unfortunately, there doesn't look to be any good workarounds at the moment according to that article

cmorgado commented 3 years ago

Hi, I've also been digging on it... and the "culprit" is WebSocket4Net Library. .. I've been experimenting with the https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket?view=net-5.0 ... But it's not helpful for you due to be dotnet5 only.

I'm going to see if can remove the WebSocket4Net dependency somehow and use this version for my use case.

My use case is building a Blazor App (webassembly) so I can track my investment in Realtime.

Thank you for your support and great work!