我正在尝试使用此代码发出请求:
public JsonObject account() throws BinanceApiException {
return (new Request(baseUrl + "v3/account"))
.sign(apiKey, secretKey, null).read().asJsonObject();
}
但我收到此错误:
BinanceApiException: ERROR: -1021, Timestamp for this request is outside of the recvWindow.
我知道这与我的计算机和服务器之间的时间同步有关。每次运行此代码时,我都不会收到此错误。过去,我通过转到 Windows 设置、日期和时间、Internet 时间设置并将我的时间同步到 time.windows.com 来解决此错误。
最佳答案
看起来像 Binance API Error: {"code":-1021,"msg":"Timestamp for this request is outside of the recvWindow."} 的副本.
您需要使用 Binance 而不是 time.windows.com 来同步您计算机上的时间。您可以使用 https://binance-docs.github.io/apidocs/spot/en/#test-connectivity检查服务器时间端点:GET /api/v3/time
另一个可能的原因(至少我遇到过) - 在 Debug模式下逐步执行请求。
默认 recvWindow 为 5 秒。如果需要,您也可以覆盖它。
关于java - 此请求的时间戳在 recvWindow 之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56247086/