binance / binance-connector-java

Simple Java connector to Binance Spot API
MIT License
399 stars 173 forks source link

On an Indian server, using WebSocket stream and combineStreams to subscribe to Bitcoin, after running for a while, the received candlestick data is delayed by half an hour. It returns to normal after restarting the service. Could you please help me identify the issue? #116

Closed 5s2j0f6c8k closed 4 months ago

5s2j0f6c8k commented 4 months ago

On an Indian server, using WebSocket stream and combineStreams to subscribe to Bitcoin, after running for a while, the received candlestick data is delayed by half an hour. It returns to normal after restarting the service. Could you please help me identify the issue?
`wsStreamClient.combineStreams(list, response -> {}, data -> { try { JsonNode baseNode = mapper.readTree(data); JsonNode jsonNode = baseNode.get("data");

        String e = jsonNode.get("e").asText();
        String s = jsonNode.get("s").asText();

        if (e.equals("kline")) {
            KLinesResp kLinesResp = new KLinesResp();
            kLinesResp.setTimestamp(jsonNode.get("k").get("t").asLong());
            kLinesResp.setOpen(jsonNode.get("k").get("o").asDouble());
            kLinesResp.setClose(jsonNode.get("k").get("c").asDouble());
            kLinesResp.setHigh(jsonNode.get("k").get("h").asDouble());
            kLinesResp.setLow(jsonNode.get("k").get("l").asDouble());
            kLinesResp.setVolume(jsonNode.get("k").get("v").asDouble());
            kLinesResp.setTurnover(jsonNode.get("k").get("V").asDouble());
            kLinesResp.setChangeType(0);

            String interval1 = jsonNode.get("k").get("i").asText();

            List<KLinesResp> list1 = new ArrayList<>();
            list1.add(kLinesResp);

            if (isWs) {
                SendKlinesResp sendKlinesResp = new SendKlinesResp();
                sendKlinesResp.setSymbol(symbol);
                sendKlinesResp.setInterval(interval1);
                sendKlinesResp.setKLinesResp(list1);
                binanceFluxProcessor.publish(sendKlinesResp);
            }
        }
    } catch (Exception e) {
        // Handle exception
    }
},
(code, reason) -> {
    // Handle close event
},
(code, reason) -> {
    // Handle error event
},
(t, response) -> {
    // Handle connection error
});

`

5s2j0f6c8k commented 4 months ago

Indian network problem, WS delay.

5s2j0f6c8k commented 4 months ago

Indian network problem, WS delay.