简体   繁体   中英

after publishing blazor-server app to server cannot get result from testnet.binance.vision [works in localhost]

This is error after publishing to the server [UBUNTU]

fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'YT-5hUsabWHhqsnewYD0_YAdubDWkaPxkx144q2ZYN0'.
      Binance.Common.BinanceClientException: Exception of type 'Binance.Common.BinanceClientException' was thrown.
         at Binance.Common.BinanceService.SendAsync[T](String requestUri, HttpMethod httpMethod, Object content)
         at Binance.Common.BinanceService.SendPublicAsync[T](String requestUri, HttpMethod httpMethod, Dictionary`2 query, Object content)
         at Binance.Spot.Market.CurrentAveragePrice(String symbol)
         at TORCHAIN.Components.CryptoTracker.PricesComponent.OnInitializedAsync() in A:\Users\sam_sepi0l\Desktop\PROJECTS\NEWFORUM\TORCHAIN\Components\CryptoTracker\PricesComponent.razor.cs:line 25
         at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

This is 25 line:

   var result = await market.CurrentAveragePrice(symbol);

At localhost it works perfectly and i get result but after publishing it says this error.

This is method call:

private static HttpClient _httpClient = new HttpClient();
public List<string> Lista = new List<string>();
protected async override Task OnInitializedAsync()
{
    #region BinanceAPI
    using (_httpClient = new HttpClient())
    {
        _httpClient.BaseAddress = new Uri("https://testnet.binance.vision");
        _httpClient.Timeout = new TimeSpan(0, 0, 5);
        _httpClient.DefaultRequestHeaders.Clear();
        _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
        _httpClient.DefaultRequestHeaders.Add("X-MBX-APIKEY", "APIKEY");
        _httpClient.DefaultRequestHeaders.Add("SecretKey", "SECRETKEY");
        var symbol = "BTCBUSD";
        var market = new Market(_httpClient);
        var result = await market.CurrentAveragePrice(symbol);
        BinancePrice? Token = JsonConvert.DeserializeObject<BinancePrice>(result);
        Lista.Add(Token!.Price.ToString());
    }
    #endregion
}

##UPDATE

I think this is problem with linux. Maybe some proxy or something i should to turn on or turn off?

There was problem with server location and sanctions from binance. i changed location to europe from america and it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM