binance / binance-spot-connector-rust

MIT License
109 stars 39 forks source link

Failed to retrieve market price while running on Ubuntu 18.04 #16

Closed oneforalone closed 4 months ago

oneforalone commented 4 months ago

Hello, i'm not able to get the btc/usdt marketprice while on Ubuntu 18.04 or linux based system. It's fine when i run it on macos, but on linux, failed with 451, and after i look at the log, it shows a little different with macos.

On linux:

ureq::response: Body entirely buffered (length: 224)

and on macos:

ureq::response: Body entirely buffered (length: 45)

Here is my codes:

use binance_spot_connector_rust::market;
use binance_spot_connector_rust::ureq::BinanceHttpClient;

use anyhow:Result;

#[derive(Default, Debug, Clone)]
struct BtcToUsdt {
  symbol: String,
  price: String,
}

#[tokio::main]
async fn main() -> Result<()> {
        let client = BinanceHttpClient::default();
        let request = market::ticker_price().symbol("BTCUSDT");
        let data = match client.send(request) {
            Ok(data) => match data.into_body_str() {
                Ok(d) => d,
                Err(_e) => return Err(CustomError("btc_price body is error".to_string())),
            },
            Err(_e) => return Err(CustomError("btc price request is error".to_string())),
        };
        let data: BtcToUsdt = serde_json::from_str(&data)?;
        println!("{data:#?}");
        Ok()
}

The question is, how can make it properly on linux?

oneforalone commented 4 months ago

Sorry, i figure it out that we're restricted cause our server is in U.S., it's the policy, not the codes.