binance / binance-futures-connector-java

MIT License
111 stars 61 forks source link

WebSocket java.io.EOFException: null #24

Open GQMai opened 6 months ago

GQMai commented 6 months ago

Anyone has the same issue when using WebSocket to receive ContinuousKline data in Mainland China using VPN?

> Task :bootRun

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.1)

2024-01-04 22:27:25.335[1704378445335] | INFO  | main       | o.g.b.BianTraderApplicationKt        - Starting BianTraderApplicationKt using Java 17.0.9 with PID 1860 (.\source\bian-trader)
2024-01-04 22:27:25.337[1704378445337] | INFO  | main       | o.g.b.BianTraderApplicationKt        - No active profile set, falling back to 1 default profile: "default"
2024-01-04 22:27:26.610[1704378446610] | INFO  | main       | o.s.b.w.e.tomcat.TomcatWebServer     - Tomcat initialized with port 8080 (http)        
2024-01-04 22:27:26.622[1704378446622] | INFO  | main       | o.a.coyote.http11.Http11NioProtocol  - Initializing ProtocolHandler ["http-nio-8080"]  
2024-01-04 22:27:26.624[1704378446624] | INFO  | main       | o.a.catalina.core.StandardService    - Starting service [Tomcat]                       
2024-01-04 22:27:26.624[1704378446624] | INFO  | main       | o.a.catalina.core.StandardEngine     - Starting Servlet engine: [Apache Tomcat/10.1.17]
2024-01-04 22:27:26.696[1704378446696] | INFO  | main       | o.a.c.c.C.[Tomcat].[localhost].[/]   - Initializing Spring embedded WebApplicationContext
2024-01-04 22:27:26.698[1704378446698] | INFO  | main       | o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1294 ms
2024-01-04 22:27:27.072[1704378447072] | INFO  | main       | o.a.coyote.http11.Http11NioProtocol  - Starting ProtocolHandler ["http-nio-8080"]
2024-01-04 22:27:27.098[1704378447098] | INFO  | main       | o.s.b.w.e.tomcat.TomcatWebServer     - Tomcat started on port 8080 (http) with context path ''
2024-01-04 22:27:27.110[1704378447110] | INFO  | main       | o.g.b.BianTraderApplicationKt        - Started BianTraderApplicationKt in 2.236 seconds (process running for 2.794)
2024-01-04 22:27:27.407[1704378447407] | INFO  | scheduling-1 | o.g.biantrader.services.BianService  - Getting continuousKlines, request={pair=PEOPLEUSDT, contractType=PERPETUAL, interval=1m, limit=60}
2024-01-04 22:27:27.409[1704378447409] | INFO  | scheduling-1 | c.b.c.f.client.utils.RequestHandler  - GET https://fapi.binance.com/fapi/v1/continuousKlines?pair=PEOPLEUSDT&contractType=PERPETUAL&interval=1m&limit=60
2024-01-04 22:27:29.734[1704378449734] | INFO  | scheduling-1 | o.g.biantrader.services.BianService  - Getting continuousKlines, request={pair=PEOPLEUSDT, contractType=PERPETUAL, interval=3m, limit=60}
2024-01-04 22:27:29.734[1704378449734] | INFO  | scheduling-1 | c.b.c.f.client.utils.RequestHandler  - GET https://fapi.binance.com/fapi/v1/continuousKlines?pair=PEOPLEUSDT&contractType=PERPETUAL&interval=3m&limit=60
2024-01-04 22:27:29.968[1704378449968] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - subscribeStream: PEOPLEUSDT, contractType: perpetual, interval: 1m
2024-01-04 22:27:29.971[1704378449971] | INFO  | scheduling-1 | c.b.c.f.c.utils.WebSocketConnection  - [Connection 1] Connecting to stream.binancefuture.com/ws/peopleusdt_perpetual@continuousKline_1m
2024-01-04 22:27:29.979[1704378449979] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - Subscribed stream: PEOPLEUSDT_perpetual@continuousKline_1m, connectionId: 1
2024-01-04 22:27:30.089[1704378450089] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - subscribeStream: PEOPLEUSDT, contractType: perpetual, interval: 3m                              
2024-01-04 22:27:30.089[1704378450089] | INFO  | scheduling-1 | c.b.c.f.c.utils.WebSocketConnection  - [Connection 2] Connecting to stream.binancefuture.com/ws/peopleusdt_perpetual@continuousKline_3m
2024-01-04 22:27:30.090[1704378450090] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - Subscribed stream: PEOPLEUSDT_perpetual@continuousKline_3m, connectionId: 2                     
2024-01-04 22:27:30.090[1704378450090] | INFO  | scheduling-1 | o.g.biantrader.services.BianService  - Getting continuousKlines, request={pair=NKNUSDT, contractType=PERPETUAL, interval=1m, limit=60} 
2024-01-04 22:27:30.091[1704378450091] | INFO  | scheduling-1 | c.b.c.f.client.utils.RequestHandler  - GET https://fapi.binance.com/fapi/v1/continuousKlines?pair=NKNUSDT&contractType=PERPETUAL&interval=1m&limit=60
2024-01-04 22:27:30.354[1704378450354] | INFO  | scheduling-1 | o.g.biantrader.services.BianService  - Getting continuousKlines, request={pair=NKNUSDT, contractType=PERPETUAL, interval=3m, limit=60}
2024-01-04 22:27:30.354[1704378450354] | INFO  | scheduling-1 | c.b.c.f.client.utils.RequestHandler  - GET https://fapi.binance.com/fapi/v1/continuousKlines?pair=NKNUSDT&contractType=PERPETUAL&interval=3m&limit=60
2024-01-04 22:27:30.603[1704378450603] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - subscribeStream: NKNUSDT, contractType: perpetual, interval: 1m
2024-01-04 22:27:30.604[1704378450604] | INFO  | scheduling-1 | c.b.c.f.c.utils.WebSocketConnection  - [Connection 3] Connecting to stream.binancefuture.com/ws/nknusdt_perpetual@continuousKline_1m
2024-01-04 22:27:30.605[1704378450605] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - Subscribed stream: NKNUSDT_perpetual@continuousKline_1m, connectionId: 3
2024-01-04 22:27:30.711[1704378450711] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - subscribeStream: NKNUSDT, contractType: perpetual, interval: 3m
2024-01-04 22:27:30.711[1704378450711] | INFO  | scheduling-1 | c.b.c.f.c.utils.WebSocketConnection  - [Connection 4] Connecting to stream.binancefuture.com/ws/nknusdt_perpetual@continuousKline_3m
2024-01-04 22:27:30.711[1704378450711] | INFO  | scheduling-1 | o.g.b.s.WebsocketStreamService       - Subscribed stream: NKNUSDT_perpetual@continuousKline_3m, connectionId: 4
2024-01-04 22:27:31.750[1704378451750] | INFO  | OkHttp https://stream.binancefuture.com/... | c.b.c.f.c.utils.WebSocketConnection  - [Connection 2] Connected to Server
2024-01-04 22:27:31.769[1704378451769] | INFO  | OkHttp https://stream.binancefuture.com/... | c.b.c.f.c.utils.WebSocketConnection  - [Connection 1] Connected to Server
2024-01-04 22:27:31.810[1704378451810] | INFO  | DefaultDispatcher-worker-3 | o.g.b.listeners.TraderDataListener   - onMessage: null                                    
2024-01-04 22:27:31.810[1704378451810] | INFO  | DefaultDispatcher-worker-1 | o.g.b.listeners.TraderDataListener   - onMessage: null                                    
2024-01-04 22:27:31.811[1704378451811] | WARN  | DefaultDispatcher-worker-3 | o.g.b.listeners.TraderDataListener   - Invalid data, pair=null, interval=null, klineData=null
2024-01-04 22:27:31.811[1704378451811] | WARN  | DefaultDispatcher-worker-1 | o.g.b.listeners.TraderDataListener   - Invalid data, pair=null, interval=null, klineData=null
2024-01-04 22:27:32.230[1704378452230] | INFO  | OkHttp https://stream.binancefuture.com/... | c.b.c.f.c.utils.WebSocketConnection  - [Connection 3] Connected to Server
2024-01-04 22:27:32.230[1704378452230] | INFO  | DefaultDispatcher-worker-1 | o.g.b.listeners.TraderDataListener   - onMessage: null
2024-01-04 22:27:32.231[1704378452231] | WARN  | DefaultDispatcher-worker-1 | o.g.b.listeners.TraderDataListener   - Invalid data, pair=null, interval=null, klineData=null
2024-01-04 22:27:32.295[1704378452295] | INFO  | OkHttp https://stream.binancefuture.com/... | c.b.c.f.c.utils.WebSocketConnection  - [Connection 4] Connected to Server
2024-01-04 22:27:32.295[1704378452295] | INFO  | DefaultDispatcher-worker-1 | o.g.b.listeners.TraderDataListener   - onMessage: null
2024-01-04 22:27:32.295[1704378452295] | WARN  | DefaultDispatcher-worker-1 | o.g.b.listeners.TraderDataListener   - Invalid data, pair=null, interval=null, klineData=null
2024-01-04 22:27:58.647[1704378478647] | WARN  | OkHttp https://stream.binancefuture.com/... | o.g.b.listeners.FailureListener      - onMessage: {"e":"continuous_kline","E":1704378482091,"ps":"PEOPLEUSDT","ct":"PERPETUAL","k":{"t":1704378420000,"T":1704378479999,"i":"1m","f":-1,"L":-1,"o":"0.02500","c":"0.0
2500","h":"0.02500","l":"0.02500","v":"0","n":0,"x":true,"q":"0.00000","V":"0","Q":"0.00000","B":"0"}}
2024-01-04 22:27:58.648[1704378478648] | WARN  | OkHttp https://stream.binancefuture.com/... | o.g.b.listeners.FailureListener      - onMessage: {"e":"continuous_kline","E":1704378482093,"ps":"NKNUSDT","ct":"PERPETUAL","k":{"t":1704378420000,"T":1704378479999,"i":"1m","f":-1,"L":-1,"o":"0.24400","c":"0.2440
0","h":"0.24400","l":"0.24400","v":"0","n":0,"x":true,"q":"0.00000","V":"0","Q":"0.00000","B":"0"}}
2024-01-04 22:27:59.578[1704378479578] | WARN  | OkHttp https://stream.binancefuture.com/... | o.g.b.listeners.FailureListener      - onMessage: {"e":"continuous_kline","E":1704378483000,"ps":"PEOPLEUSDT","ct":"PERPETUAL","k":{"t":1704378420000, "T":1704378479999, "i":"1m", "f":-1, "L":-1, "o":"0.02500", "c
":"0.02500", "h":"0.02500", "l":"0.02500", "v":"0", "n":0, "x":true, "q":"0", "V":"0", "Q":"0", "B":"0"}}
2024-01-04 22:27:59.578[1704378479578] | WARN  | OkHttp https://stream.binancefuture.com/... | o.g.b.listeners.FailureListener      - onMessage: {"e":"continuous_kline","E":1704378483000,"ps":"NKNUSDT","ct":"PERPETUAL","k":{"t":1704378420000, "T":1704378479999, "i":"1m", "f":-1, "L":-1, "o":"0.24400", "c":"
0.24400", "h":"0.24400", "l":"0.24400", "v":"0", "n":0, "x":true, "q":"0", "V":"0", "Q":"0", "B":"0"}}
2024-01-04 22:28:30.875[1704378510875] | ERROR | OkHttp https://stream.binancefuture.com/... | c.b.c.f.c.utils.WebSocketConnection  - [Connection 1] Failure
java.io.EOFException: null                                                                                                                                  
        at okio.RealBufferedSource.require(RealBufferedSource.kt:202)                                                                                       
        at okio.RealBufferedSource.readByte(RealBufferedSource.kt:212)                                                                                      
        at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.kt:119)
        at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:102)
        at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
        at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:842)
Sailboats commented 2 months ago

兄弟,同样的问题,我更诡异,我是在阿里云香港服务器,我是跑起来之后很长一段时间之后才会断开,和你一样的报错,我看这上面有很多websocket的问题,拉你进技术群一起探讨下吧,人多力量大,加我微信Silenceeeeeeeeeeee