Igosuki/binance-rs-async

WebSocketEvent not parsed properly

vikulikov opened this issue · 3 comments

For some reason I get the error error on event loop: missing field "e" at line 1 column 186 with this code.
And column reported is always different error on event loop: missing field "e" at line 1 column 2337

async fn subscribe_to_streams<C>(
        &self,
        streams: Vec<String>,
        on_event: C,
        keep_running: &AtomicBool,
    ) where
        C: FnMut(WebsocketEvent) -> Result<(), binance::errors::Error>,
    {
        let mut websocket_connector: WebSockets<'_, WebsocketEvent> = WebSockets::new(on_event);
        websocket_connector.connect_multiple(streams).await.unwrap(); // TODO: handle result
        if let Err(e) = websocket_connector.event_loop(keep_running).await {
            error!(" {}: error on event loop: {}", self.cfg.name, e); // TODO: handle error
        }
        websocket_connector.disconnect().await.unwrap() // TODO: handle unwrap
    }

steams are just strings such as "btcusdt@depth@100ms"

Well, it says what it says, if there is a missing "e", most likely you added a stream where events don't have "e" which is handled by WebsocketEventUntag as shown in the examples section

Oh, sorry. Didn't see that example. Will try

Thx. It's working!