deepstream.io-client-java icon indicating copy to clipboard operation
deepstream.io-client-java copied to clipboard

Java client hangs when connecting to the server with secure web socket

Open matbos opened this issue 8 years ago • 3 comments

When I try to connect to the server from java client, application hangs and the following exception gets printed in the console:

Exception in thread "Thread-15" java.nio.BufferOverflowException
	at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:363)
	at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:342)
	at sun.nio.ch.IOUtil.write(IOUtil.java:60)
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
	at org.java_websocket.SSLSocketChannel2.close(SSLSocketChannel2.java:270)
	at org.java_websocket.WebSocketImpl.closeConnection(WebSocketImpl.java:453)
	at org.java_websocket.WebSocketImpl.closeConnection(WebSocketImpl.java:472)
	at org.java_websocket.WebSocketImpl.eot(WebSocketImpl.java:509)
	at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:249)
	at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188)
	at java.lang.Thread.run(Thread.java:745)

Looks like it keeps on waiting for the countdown latch in this line but it never gets decremented. It does not matter if I remove authorization data from the login request, it still occurs.

What is weird is when I connect to the very same server with JavaScript client, everything works as expected. When WSS is disabled the client connects just fine but since JS client connects without any problem(with WSS enabled) I rule out the possibility that the WSS is poorly configured. Did anyone else encounter this behavior?

Below is the code I use to setup a connection:

val ds = DeepstreamClient(deepstreamEndpoint) // "wss://myaddress:63200"
val loginReq = Gson().toJsonTree(LoginData(basicId, basicSecret)) 
val result = ds.login(loginReq) // << in my code it hangs here
if (result.loggedIn()) {
    logger.info("Deepstream: Log in success!")
} else {
    logger.info("Deepstream: Log in error!")
}

Using java client with version 2.0.4 and Linux Deepstream server 2.1.3.

matbos avatar Aug 29 '17 11:08 matbos

hm, I wonder if this is related to https://github.com/deepstreamIO/deepstream.io-client-java/issues/104 @yasserf @AlexBHarley thoughts?

WolframHempel avatar Aug 29 '17 11:08 WolframHempel

It doesn't seem to be. I just tested and while it blocks, my CPU doesn't go through the roof

jamesalexscott avatar Sep 02 '17 02:09 jamesalexscott

Does the server receive the connection / print out anything with debug logs when you connect with a WSS connection?

yasserf avatar Sep 03 '17 08:09 yasserf