binance-spot-connector-rust
binance-spot-connector-rust copied to clipboard
How do I set credentials using Websocket API?
I'm trying to use the Websocket version of the api but I don't see any place to put the credentials
There is a lot of unclarity in the docs and I don't see anything in the examples explaining or showing how this is done for the Websocket side.
here is a trivial snippet which leads to a crash when unwrapping the connection. The error isn't clear as to what the issue is
use binance_spot_connector_rust::{
http::Credentials,
market::klines::KlineInterval, market_stream::kline::KlineStream,
tokio_tungstenite::BinanceWebSocketClient,
};
use env_logger::Builder;
use futures_util::StreamExt;
#[tokio::main]
async fn main() {
let res = BinanceWebSocketClient::connect_async("wss://testnet.binance.vision/ws-api/v3.").await;
if res.is_err() {
println!("{:?}", res.as_ref().err());
}
let (mut conn, y ) = res.unwrap();
/// use binance_spot_connector_rust::market_stream::ticker::TickerStream;
///
let individual_symbol_stream = binance_spot_connector_rust::market_stream::ticker::TickerStream::from_symbol("BTCUSDT");
conn.subscribe(vec![
&individual_symbol_stream.into()
]
).await;
println!("Hello, world!");
}
Some(Http(Response { status: 404, version: HTTP/1.1, headers: {"content-length": "48", "connection": "close", "date": "Mon, 29 Jan 2024 13:10:39 GMT", "server": "X", "x-mbx-uuid": "656dbd59-91ed-4b67-9d61-88b87ec8a82a", "x-cache": "Error from cloudfront", "via": "1.1 7d30cf029bde247eef16106ceffb39ca.cloudfront.net (CloudFront)", "x-amz-cf-pop": "TLV50-C1", "x-amz-cf-id": "83iERQTXPkgGVJNB7GqEk2X3gjH9HIN2v9hwqF22f_YuaIYmNpxBqA=="}, body: None }))
thread 'main' panicked at src/main.rs:15:30:
called `Result::unwrap()` on an `Err` value: Http(Response { status: 404, version: HTTP/1.1, headers: {"content-length": "48", "connection": "close", "date": "Mon, 29 Jan 2024 13:10:39 GMT", "server": "X", "x-mbx-uuid": "656dbd59-91ed-4b67-9d61-88b87ec8a82a", "x-cache": "Error from cloudfront", "via": "1.1 7d30cf029bde247eef16106ceffb39ca.cloudfront.net (CloudFront)", "x-amz-cf-pop": "TLV50-C1", "x-amz-cf-id": "83iERQTXPkgGVJNB7GqEk2X3gjH9HIN2v9hwqF22f_YuaIYmNpxBqA=="}, body: None })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace