我正在尝试使用 Coinigy websocket api 的代码数据来获取实时交易流和加密资产的价格。
我尝试了以下演示,但没有成功,我得到以下响应:
“套接字未通过身份验证”
internal class MyListener:BasicListener
{
public void onConnected(Socket socket)
{
Console.WriteLine("connected got called");
}
public void onDisconnected(Socket socket)
{
Console.WriteLine("disconnected got called");
}
public void onConnectError(Socket socket, ErrorEventArgs e)
{
Console.WriteLine("on connect error got called");
}
public void onAuthentication(Socket socket, bool status)
{
Console.WriteLine(status ? "Socket is authenticated" : "Socket is not authenticated");
}
public void onSetAuthToken(string token, Socket socket)
{
token = "{'apiKey' : 'KEYXXXXXX', 'apiSecret' : 'SECRETXXXX'}"; //<---MY key and secret
socket.setAuthToken(token);
Console.WriteLine("on set auth token got called");
}
}
internal class Program
{
public static void Main(string[] args)
{
var socket=new Socket("wss://sc-02.coinigy.com/socketcluster/");
socket.setListerner(new MyListener());
socket.setReconnectStrategy(new ReconnectStrategy().setMaxAttempts(30));
socket.connect();
//Other code calling the websocket....
//Other code calling the websocket....
//Other code calling the websocket....
Console.ReadKey();
}
}