带有BinanceAPI的WebSocketSharp

带有BinanceAPI的WebSocketSharp,websocket,connection,binance,websocket-sharp,connection-close,Websocket,Connection,Binance,Websocket Sharp,Connection Close,我与binanceApi有连接,我有一个断开连接的问题, API断开连接,我不知道原因,我想保持连接,直到我的订单到位。我会发布我的代码,也许有人能帮我 我已经在localhost上用websocketsharp创建了另外两个项目进行测试,所有断开连接都会正常启动 我认为你的Ping不正确。服务器等待“pong”消息 UPD 根据binance文档= public class WSMonitorada { public WebSocket ws; public Us

我与binanceApi有连接,我有一个断开连接的问题, API断开连接,我不知道原因,我想保持连接,直到我的订单到位。我会发布我的代码,也许有人能帮我

我已经在localhost上用websocketsharp创建了另外两个项目进行测试,所有断开连接都会正常启动


我认为你的Ping不正确。服务器等待“pong”消息

UPD 根据binance文档=

 public class WSMonitorada
{      
    public WebSocket ws;
    public Usuario User;
    public Timer timerKeepAlive = new Timer();

    public WSMonitorada(Usuario user, string key)
    {        
         timerKeepAlive.Interval = TimeSpan.FromMinutes(15).TotalMilliseconds;
         timerKeepAlive.Elapsed += (object source, ElapsedEventArgs e) =>
          {
             BinanceUserDataStream.KeepAlive(User.BinanceAPIKey, user.BinanceAPISecret);
          };
          timerKeepAlive.Start();

                ws = new WebSocket("wss://stream.binance.com:9443/ws/" + key);
                ws.WaitTime = TimeSpan.FromSeconds(5);  
                ws.Log.Level = LogLevel.Trace;
                ws.Log.File = "C:\\LogConexao\\" + user.nome + ".txt";    
                //log file never show close event        
                ws.OnOpen += (sender, e) =>
                {
                //logic here wors perfect
                };                    
                ws.EmitOnPing = true;
                ws.OnMessage += (sender, e) =>
                {
                    if (e.IsPing)
                    {
                        ws.Ping();
                        return;
                    }
                    //logic here wors perfect
                }
                ws.OnClose += (sender, e) =>
                {                  

                // i have a logic here to analyse if i have a opened order and reconnect again but event never fire
                 ws.Connect();      
                };
                ws.Connect();    
    }
}