Java-WebSocket: Library test error (version1.3.9)
Hi I am testing a new version (1.3.9). Previous version (1.3.8) works normally. In version 1.3.9, the following error occurs.
This site is a non-personal site for testing Websocket
===== TEST Log ========= SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. onOpen :: org.java_websocket.handshake.HandshakeImpl1Server@5b40c349 buffer.array() Size :: 16384 buffer.position() :: 4 payload.limit() :: 4458 onMessage :: {“amount”:“0”,“data”:[{“cont_no”:31112459,“price”:“6514000”,“total”:“35827”,“transaction_date”:“2018-11-15 14:07:56.159886”,“type”:“dn”,“units_traded”:“0.0055”},{“cont_no”:31112458,“price”:“6526000”,“total”:“4558411”,“transaction_date”:“2018-11-15 14:07:55.081087”,“type”:“up”,“units_traded”:“0.6985”},{“cont_no”:31112457,“price”:“6524000”,“total”:“315109.2”,“transaction_date”:“2018-11-15 14:07:51.389782”,“type”:“dn”,“units_traded”:“0.0483”},{“cont_no”:31112456,“price”:“6524000”,“total”:“978600”,“transaction_date”:“2018-11-15 14:07:51.335102”,“type”:“dn”,“units_traded”:“0.15”},{“cont_no”:31112455,“price”:“6524000”,“total”:“293580”,“transaction_date”:“2018-11-15 14:07:51.273080”,“type”:“dn”,“units_traded”:“0.045”},{“cont_no”:31112454,“price”:“6526000”,“total”:“54165.8”,“transaction_date”:“2018-11-15 14:07:47.887111”,“type”:“up”,“units_traded”:“0.0083”},{“cont_no”:31112453,“price”:“6526000”,“total”:“117468”,“transaction_date”:“2018-11-15 14:07:44.521642”,“type”:“up”,“units_traded”:“0.018”},{“cont_no”:31112452,“price”:“6526000”,“total”:“2950404.6”,“transaction_date”:“2018-11-15 14:07:43.291693”,“type”:“up”,“units_traded”:“0.4521”},{“cont_no”:31112451,“price”:“6526000”,“total”:“1999566.4”,“transaction_date”:“2018-11-15 14:07:21.958526”,“type”:“up”,“units_traded”:“0.3064”},{“cont_no”:31112450,“price”:“6526000”,“total”:“7831.2”,“transaction_date”:“2018-11-15 14:07:20.699640”,“type”:“up”,“units_traded”:“0.0012”},{“cont_no”:31112449,“price”:“6522000”,“total”:“1495494.6”,“transaction_date”:“2018-11-15 14:07:03.538408”,“type”:“dn”,“units_traded”:“0.2293”},{“cont_no”:31112448,“price”:“6522000”,“total”:“4280388.6”,“transaction_date”:“2018-11-15 14:06:53.179685”,“type”:“dn”,“units_traded”:“0.6563”},{“cont_no”:31112447,“price”:“6522000”,“total”:“40436.4”,“transaction_date”:“2018-11-15 14:06:52.492949”,“type”:“dn”,“units_traded”:“0.0062”},{“cont_no”:31112446,“price”:“6522000”,“total”:“40436.4”,“transaction_date”:“2018-11-15 14:06:44.073058”,“type”:“dn”,“units_traded”:“0.0062”},{“cont_no”:31112445,“price”:“6522000”,“total”:“40436.4”,“transaction_date”:“2018-11-15 14:06:36.259743”,“type”:“dn”,“units_traded”:“0.0062”},{“cont_no”:31112444,“price”:“6522000”,“total”:“25435.8”,“transaction_date”:“2018-11-15 14:06:31.207640”,“type”:“dn”,“units_traded”:“0.0039”},{“cont_no”:31112443,“price”:“6522000”,“total”:“253053.6”,“transaction_date”:“2018-11-15 14:06:31.144198”,“type”:“dn”,“units_traded”:“0.0388”},{“cont_no”:31112442,“price”:“6522000”,“total”:“40436.4”,“transaction_date”:“2018-11-15 14:06:29.191360”,“type”:“dn”,“units_traded”:“0.0062”},{“cont_no”:31112441,“price”:“6526000”,“total”:“6526”,“transaction_date”:“2018-11-15 14:06:28.253211”,“type”:“up”,“units_traded”:“0.001”},{“cont_no”:31112440,“price”:“6522000”,“total”:“34566.6”,“transaction_date”:“2018-11-15 14:06:26.096669”,“type”:“dn”,“units_traded”:“0.0053”},{“cont_no”:31112439,“price”:“6522000”,“total”:“40436.4”,“transaction_date”:“2018-11-15 14:06:23.553106”,“type”:“dn”,“units_traded”:“0.0062”},{“cont_no”:31112438,“price”:“6526000”,“total”:“387644.4”,“transaction_date”:“2018-11-15 14:06:21.333745”,“type”:“up”,“units_traded”:“0.0594”},{“cont_no”:31112437,“price”:“6526000”,“total”:“799435”,“transaction_date”:“2018-11-15 14:06:20.720158”,“type”:“up”,“units_traded”:“0.1225”},{“cont_no”:31112436,“price”:“6526000”,“total”:“54165.8”,“transaction_date”:“2018-11-15 14:06:20.351173”,“type”:“up”,“units_traded”:“0.0083”},{“cont_no”:31112435,“price”:“6526000”,“total”:“3000002.2”,“transaction_date”:“2018-11-15 14:06:15.394100”,“type”:“up”,“units_traded”:“0.4597”},{“cont_no”:31112434,“price”:“6520000”,“total”:“40424”,“transaction_date”:“2018-11-15 14:06:14.663459”,“type”:“dn”,“units_traded”:“0.0062”},{“cont_no”:31112433,“price”:“6526000”,“total”:“202306”,“transaction_date”:“2018-11-15 14:06:13.778676”,“type”:“up”,“units_traded”:“0.031”},{“cont_no”:31112432,“price”:“6520000”,“total”:“40424”,“transaction_date”:“2018-11-15 14:06:07.172099”,“type”:“dn”,“units_traded”:“0.0062”},{“cont_no”:31112431,“price”:“6526000”,“total”:“54165.8”,“transaction_date”:“2018-11-15 14:06:04.471295”,“type”:“up”,“units_traded”:“0.0083”},{“cont_no”:31112430,“price”:“6526000”,“total”:“4736570.8”,“transaction_date”:“2018-11-15 14:06:02.692485”,“type”:“up”,“units_traded”:“0.7258”},{“cont_no”:31112429,“price”:“6525000”,“total”:“5262412.5”,“transaction_date”:“2018-11-15 14:06:02.633466”,“type”:“up”,“units_traded”:“0.8065”}],“header”:{“currency”:“BTC”,“service”:“transaction”},“status”:“0000”} buffer.array() Size :: 16384 buffer.position() :: 4 payload.limit() :: 1257 onMessage :: {“data”:{“asks”:[{“price”:“6526000”,“quantity”:“17.33115603”},{“price”:“6534000”,“quantity”:“1.1416”},{“price”:“6535000”,“quantity”:“2.43094694”},{“price”:“6540000”,“quantity”:“.0411”},{“price”:“6542000”,“quantity”:“.3”},{“price”:“6543000”,“quantity”:“.2”},{“price”:“6544000”,“quantity”:“.0501”},{“price”:“6545000”,“quantity”:“.0002”},{“price”:“6546000”,“quantity”:“.302”},{“price”:“6549000”,“quantity”:“.002”},{“price”:“6550000”,“quantity”:“5.9119”},{“price”:“6555000”,“quantity”:“.126”},{“price”:“6556000”,“quantity”:“.482”},{“price”:“6558000”,“quantity”:“2.5”},{“price”:“6560000”,“quantity”:“.0102”}],“bids”:[{“price”:“6514000”,“quantity”:“2.0945”},{“price”:“6512000”,“quantity”:“.3579”},{“price”:“6511000”,“quantity”:“.0876”},{“price”:“6509000”,“quantity”:“2.5”},{“price”:“6506000”,“quantity”:“.3651”},{“price”:“6505000”,“quantity”:“.001”},{“price”:“6501000”,“quantity”:“.0033”},{“price”:“6500000”,“quantity”:“1.2584”},{“price”:“6495000”,“quantity”:“.13”},{“price”:“6491000”,“quantity”:“25”},{“price”:“6490000”,“quantity”:“.416”},{“price”:“6484000”,“quantity”:“.3877”},{“price”:“6480000”,“quantity”:“2.65”},{“price”:“6473000”,“quantity”:“.2767”},{“price”:“6470000”,“quantity”:“.5977”}]},“header”:{“currency”:“BTC”,“service”:“orderbook”},“status”:“0000”} buffer.array() Size :: 10829 buffer.position() :: 4 payload.limit() :: 10827 onError :: java.lang.IndexOutOfBoundsException at java.nio.Buffer.checkBounds(Buffer.java:559) at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:181) at org.java_websocket.drafts.Draft_6455.translateSingleFrame(Draft_6455.java:494) at org.java_websocket.drafts.Draft_6455.translateFrame(Draft_6455.java:628) at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:378) at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:218) at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:425) at java.lang.Thread.run(Thread.java:744) onClose :: 1006:null:false
========= Test source =====
package test;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;
public class WebSocketTest extends WebSocketClient
{
public static void main(String[] args)
{
Map<String, String> header = new HashMap<String, String>();
header.put("Origin", "https://www.bithumb.com");
WebSocketTest websocket = new WebSocketTest(URI.create("wss://wss.bithumb.com/public"), new Draft_6455(), header);
websocket.connect();
}
public WebSocketTest(URI serverUri, Draft protocolDraft, Map<String, String> httpHeaders)
{
super(serverUri, protocolDraft, httpHeaders);
}
@Override
public void onOpen(ServerHandshake handshakedata)
{
System.out.println("onOpen :: " + handshakedata);
}
@Override
public void onMessage(String message)
{
System.out.println("onMessage :: " + message);
}
@Override
public void onClose(int code, String reason, boolean remote)
{
System.out.println("onClose :: " + code + ":"+reason + ":"+remote);
}
@Override
public void onError(Exception ex)
{
System.err.println("onError :: ");
ex.printStackTrace();
}
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17
For now, I’ve made a quick diff of the changes. You can view it here. (whitespace issues shouldn’t be visible)
@PhilipRoman @marci4 Hi~~ all I found the reason for the error. The error occurs if the message is larger than the size of the receive buffer (16,384 bytes). If it is bigger than the buffer, the message is received and received, but there is a problem in message assembly.
I fixed the error by modifying the source as shown below. I hope this error has been fixed in the next version.
Draft_6455.java.zip