Closed mahieddine closed 6 years ago
This happens because of slash at the beginning. Quickfix attached, but i get the problem with encoding. binance-fix.zip
Noticed it yesterday too and couldn't figure out what I was doing wrong. The node.js library was connecting just find. Thanks for reporting.
thank you @trojanflash your patch fixed the connection issue but as you mentioned there is still this problem with the encoding (as it seems), maybe Binance changed the compression algorithm?
@mahieddine also fix the problem, see attach fixed-problem-with-websockets.zip
@trojanflash I'm still getting the wrong encoding messages with your last fix.
PS: With regards to your 1st fix, Isn't it just enough to strip the first "/":
private BinanceStreamingService createStreamingService(ProductSubscription subscription) {
String subs = buildSubscriptionStreams(subscription);
//Strip the start:
subs = subs .startsWith("/") ? subs .substring(1) : subs ;
String path = API_BASE_URI + "stream?streams=" + subs;
return new BinanceStreamingService(path, subscription);
}
@daniel-cohen you can checkout my forked repository (https://github.com/trojanflash/xchange-stream) and run BinanceManualExample. There is some more changes there such as moving to xchange 4.3.4 ect... (code style a little bit corrupted)
@daniel-cohen
PS: With regards to your 1st fix, Isn't it just enough to strip the first "/":
subs = subs .startsWith("/") ? subs .substring(1) : subs ;
i think it is a little bit ugly
thank you @trojanflash it worked perfectly so if i understand correctly the patch for the netty part, we were reading the message before uncompressing it right? Anyway once again thank you very much for your help, will you make a PR for that ?
@mahieddine welcome. There are a few changes in commit besides this fix, so i don't know whether my PR will be accepted.
@trojanflash Thanks for the fix! I had some time to check your fork today, got it working and extracted the code into a PR for this issue. Hope you don't mind.
@daniel-cohen no problem, glad to help
Thanks @daniel-cohen and @trojanflash
On what version was this merged? Was the fix released already? I'm still getting this error on 4.3.3-SNAPSHOT.
91743 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.service.netty.WebSocketClientHandler - WebSocket Client connected!
91744 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.binance.BinanceStreamingService - Resubscribing channels
91744 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.service.netty.WebSocketClientHandler - WebSocket Client received closing
91745 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.service.netty.WebSocketClientHandler - WebSocket Client disconnected!
91745 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.binance.BinanceStreamingService - Reopening websocket because it was closed by the host
91745 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.binance.BinanceStreamingService - Connecting to wss://stream.binance.com:9443/stream
I also got the same error, frequency of getting this error is very high (atleast once in every 15/20 minutes). This is resulting inconsistent orderbook. Does anyone know whether fix was already applied.
08:21:20.883 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.service.netty.WebSocketClientHandler - WebSocket Client received closing 08:21:20.887 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.service.netty.WebSocketClientHandler - WebSocket Client disconnected! 08:21:20.887 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.binance.BinanceStreamingService - Reopening websocket because it was closed by the host 08:21:20.888 [nioEventLoopGroup-2-2] INFO info.bitrich.xchangestream.binance.BinanceStreamingService - Connecting to wss://stream.binance.com:9443/stream 08:21:21.715 [nioEventLoopGroup-2-3] INFO info.bitrich.xchangestream.service.netty.WebSocketClientHandler - WebSocket Client connected! 08:21:21.715 [nioEventLoopGroup-2-3] INFO info.bitrich.xchangestream.binance.BinanceStreamingService - Resubscribing channels
Thank you, I appreciate any help regarding this error.
Still not work on develop branch. It seems to some commits( 78c57d9 ...) in pull request #142 no full merged.
logs
2018-07-24 17:00:00.925 INFO 5962 --- [cTaskExecutor-2] i.b.x.binance.BinanceStreamingExchange : Calling Remote Init...
2018-07-24 17:00:04.146 INFO 5962 --- [cTaskExecutor-2] i.b.x.binance.BinanceStreamingService : Connecting to wss://stream.binance.com:9443/stream
2018-07-24 17:00:06.251 INFO 5962 --- [ntLoopGroup-2-1] i.b.x.s.netty.WebSocketClientHandler : WebSocket Client disconnected!
2018-07-24 17:00:06.252 INFO 5962 --- [ntLoopGroup-2-1] i.b.x.binance.BinanceStreamingService : Reopening websocket because it was closed by the host
2018-07-24 17:00:06.255 ERROR 5962 --- [cTaskExecutor-2] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected error occurred invoking async method 'public void com.idataitech.dcmh.market.Binance.run()'.
io.netty.handler.codec.CodecException: invalid WebSocket Extension handshake for "permessage-deflate; server_no_context_takeover; client_no_context_takeover"
at io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler.channelRead(WebSocketClientExtensionHandler.java:111) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1388) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1159) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1202) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1414) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:945) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:141) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
2018-07-24 17:00:06.280 INFO 5962 --- [ntLoopGroup-2-1] i.b.x.binance.BinanceStreamingService : Connecting to wss://stream.binance.com:9443/stream
2018-07-24 17:00:07.880 WARN 5962 --- [ntLoopGroup-2-2] i.b.x.binance.BinanceStreamingService : Problem with reconnect
io.netty.handler.codec.CodecException: invalid WebSocket Extension handshake for "permessage-deflate; server_no_context_takeover; client_no_context_takeover"
at io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler.channelRead(WebSocketClientExtensionHandler.java:111) ~[netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1388) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1159) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1202) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1414) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:945) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:141) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.21.Final.jar:4.1.21.Final]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
2018-07-24 17:00:07.904 INFO 5962 --- [ntLoopGroup-2-2] i.b.x.s.netty.WebSocketClientHandler : WebSocket Client disconnected!
2018-07-24 17:00:07.904 INFO 5962 --- [ntLoopGroup-2-2] i.b.x.binance.BinanceStreamingService : Reopening websocket because it was closed by the host
2018-07-24 17:00:07.904 INFO 5962 --- [ntLoopGroup-2-2] i.b.x.binance.BinanceStreamingService : Connecting to wss://stream.binance.com:9443/stream
2018-07-24 17:00:09.518 WARN 5962 --- [ntLoopGroup-2-3] i.b.x.binance.BinanceStreamingService : Problem with reconnect
should not use WebSocketClientCompressionHandler.
It seems like the binance streaming doesn't work anymore this is what i'm getting while running "BinanceManualExample.java" in the tests folder, the client just keep getting disconnected as soon as it gets connected
How can i fix this ? thank you