[英]after publishing blazor-server app to server cannot get result from testnet.binance.vision [works in localhost]
這是發布到服務器后的錯誤 [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)
這是 25 行:
var result = await market.CurrentAveragePrice(symbol);
在本地主機上,它運行完美,我得到了結果,但在發布后它說這個錯誤。
這是方法調用:
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
}
##更新
我認為這是 linux 的問題。也許是一些代理或我應該打開或關閉的東西?
服務器位置和 binance 的制裁存在問題。 我將位置從美國更改為歐洲並且它有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.