币安期货测试网络没有数据 - 用户数据 tream

No data from the Binance futures test network - user data tream

提问人:Vadym Melnychenko 提问时间:10/28/2023 更新时间:10/28/2023 访问量:18

问:

我正在尝试使用 websockets 在币安测试网络(期货)上获取我的未平仓订单的更新。

我正在使用: wss://stream.binancefuture.com/ws/listenKey

这是我如何获取listenKey的代码:

public static String getListenKey() throws IOException {
        String testFuturesNet = "https://testnet.binancefuture.com";
        String futuresNet = "";
        String endPoint = "/fapi/v1/listenKey";
        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody requestBody = RequestBody.create("{}", mediaType);
        Request request = new Request.Builder()
                .url(testFuturesNet+endPoint)
                .post(requestBody)
                .addHeader("X-MBX-APIKEY", test_pk)
                .build();
        Call call = client.newCall(request);
        Response response = call.execute();
        String listenKey;
        JSONObject listenKeyObj;
        try {
            listenKeyObj = new JSONObject(response.body().string());
            listenKey = listenKeyObj.getString("listenKey");
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        Log.d("iks", listenKey);
        return listenKey;
    }

然后我连接到 wss://stream.binancefuture.com/ws/myListenKey。
我得到代码 101,所以连接正常
但是我没有从流中收到任何消息

为了测试,我打印了套接字中的所有内容:

    public void onMessage(String message) {
        Log.d("iks", message);
        notifySubscribers(message);
    }

websocket 来自:import org.java_websocket.client.WebSocketClient
知道我做错了什么吗?
谢谢

java websocket 币安

评论


答: 暂无答案