Even when connecting Web3j via WebSocket, I can’t receive blocks instantly

2 weeks ago 11
ARTICLE AD BOX

I made sure the RPC URL definitely starts with wss, but Web3j still keeps fetching blocks at specific intervals instead of receiving them in real time.
Do I need to call a different method?
My Web3j version is 5.0.1.

WebSocketService ws = new WebSocketService(chain.getWsRpc(), false); try { ws.connect(); } catch (ConnectException e) { log.error("Connection Error: {}", e.getMessage(), e); } Web3j web3j1 = Web3j.build(ws); web3j1.blockFlowable(false).subscribe(block -> { System.out.println("New block number: " + block.getBlock().getNumber()); });

It fetches multiple blocks in batches every 3–4 seconds.
The networks I used are Polygon (amoy) and Infura.io’s free plan RPC.

Read Entire Article