B4J Question Websocket Login Request PRoblem

tufanv

Expert
Licensed User
Longtime User
Hello,

I have registered for a wss data feed service. My problem is, I can't send a login request to their wss as described in the documentation. Probably I am doing it wrong. Documentation says the wss address is for example:

wss://wss.example.com/websocket

I can connect to it and I get connected message under ws_connected. Documentation says with the first connection you must send login request like this :

{
"_id" : 64,
"user" : "userName",
"password" : "user_pass",
"info" : "user_info",
"resource" : "fxplus"
}


I am not sure if I am doing right but under ws_connected I use this:

B4X:
Sub ws_connected
    Log("connected")
   
ws.SendText("_id=64&user=user&password=pass&info=userInfo&resource=fxplus")
End Sub

But this gives me this :

B4X:
2019-06-20 13:42:14.596:INFO::main: Logging initialized @663ms to org.eclipse.jetty.util.log.StdErrLog
connected
java.nio.channels.ClosedChannelException
    at org.eclipse.jetty.io.WriteFlusher.onClose(WriteFlusher.java:532)
    at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onIncompleteFlush(SslConnection.java:530)
    at org.eclipse.jetty.io.AbstractEndPoint$2.onIncompleteFlush(AbstractEndPoint.java:54)
    at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:332)
    at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:380)
    at org.eclipse.jetty.websocket.common.io.FrameFlusher.flush(FrameFlusher.java:218)
    at org.eclipse.jetty.websocket.common.io.FrameFlusher.process(FrameFlusher.java:157)
    at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
    at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224)
    at org.eclipse.jetty.websocket.common.io.FrameFlusher.enqueue(FrameFlusher.java:90)
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.outgoingFrame(AbstractWebSocketConnection.java:495)
    at org.eclipse.jetty.websocket.client.io.WebSocketClientConnection.outgoingFrame(WebSocketClientConnection.java:72)
    at org.eclipse.jetty.websocket.common.WebSocketSession.close(WebSocketSession.java:223)
    at org.eclipse.jetty.websocket.common.WebSocketSession.close(WebSocketSession.java:202)
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onConnectionStateChange(AbstractWebSocketConnection.java:353)
    at org.eclipse.jetty.websocket.common.io.IOState.notifyStateListeners(IOState.java:184)
    at org.eclipse.jetty.websocket.common.io.IOState.onReadFailure(IOState.java:498)
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:547)
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:391)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
    at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
    at java.base/java.lang.Thread.run(Thread.java:844)
disconnected
disconnected

can you tell me what I am doing wrong here ?

thanks
 

DonManfred

Expert
Licensed User
Longtime User
like this :

{
"_id" : 64,
"user" : "userName",
"password" : "user_pass",
"info" : "user_info",
"resource" : "fxplus"
}
Looks like an jsonstructure.
ws.SendText("_id=64&user=user&password=pass&info=userInfo&resource=fxplus")
Why you are not sending the jsonstructure? You are sending it like it would be an httpcall in a get call. Looks wrong to me
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…