无法获得与 gdax 工作的安全 websocket 连接

Cant get a secure websocket connection to gdax working

我正在尝试从 C#(目标框架:Core 2.0)连接到 GDAX websocket 提要

I'm using this NodeJS implementation as a reference.

我的代码:

var ws = new WebSocket("wss://ws-feed.gdax.com");
ws.Security.AllowUnstrustedCertificate = true; // doesn't matter if I remove this line
ws.Send(json);
ws.MessageReceived += (sender, args) => _log.LogInformation(args.Message);

其中 json (Reference):

{
  "type": "subscribe",
  "product_ids": [
    "BTC-EUR"
  ],
  "channels": [
    "ticker"
  ]
}

我在日志中没有看到任何错误,我为 WebSocket 尝试了不同的库。我对使用其他库的解决方案没意见。

        var ws = new WebSocket4Net.WebSocket(url);
        ws.Open();


        ws.DataReceived += (sender, args) => Console.WriteLine(args.Data);
        ws.MessageReceived += (sender, args) => Console.WriteLine(args.Message);
        ws.Opened += (sender, args) =>
        {
            Console.WriteLine("opened: " + args);
            ws.Send(json);
        };
        ws.Error += (sender, args) => Console.WriteLine("error: " + args);
        Console.ReadLine();

问题是我在调用 Open 后立即发送。我应该等待并发送 Opened 事件。