Albert
01/04/2019, 10:15 AMval connection = WebsocketClient.nonBlocking(
Uri.of("<ws://localhost:8080>")
)
connection.send(WsMessage("{}"))
The connection is not opened when sending and result into:
Exception in thread "main" org.java_websocket.exceptions.WebsocketNotConnectedException
at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:608)
at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:585)
at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:337)
at org.http4k.client.AdaptingWebSocket.send(WebsocketClient.kt:58)
at TestKt.main(Test.kt:50)
It is "works" when I add a Thread.sleep(20):
val connection = WebsocketClient.nonBlocking(
Uri.of("<ws://localhost:8080>")
)
Thread.sleep(20)
connection.send(WsMessage("{}"))
But this isn't the way to go