B4J Question Error while connecting to socket

ajk

Active Member
Licensed User
I still get jetty websocket error. Client connects correctly after this message client can send data to server, but if error fire second or third time then connection is not possible (debug release).
B4X:
Waiting for debugger to connect...
Program started.
2020-06-22 09:15:24.021:INFO::main: Logging initialized @2480ms to org.eclipse.jetty.util.log.StdErrLog
2020-06-22 09:15:25.016:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_211-b12
2020-06-22 09:15:25.223:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2020-06-22 09:15:25.223:INFO:oejs.session:main: No SessionScavenger set, using defaults
2020-06-22 09:15:25.224:INFO:oejs.session:main: node0 Scavenging every 660000ms
2020-06-22 09:15:25.322:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@1ca8de8{/,file:///home/dd/tempjars/www,AVAILABLE}
2020-06-22 09:15:25.325:INFO:oejs.AbstractNCSARequestLog:main: Opened /home/dd/tempjars/logs/b4j-2020_06_22.request.log
2020-06-22 09:15:25.335:INFO:oejs.AbstractConnector:main: Started ServerConnector@1fdea72{HTTP/1.1,[http/1.1]}{0.0.0.0:90}
2020-06-22 09:15:25.337:INFO:oejs.Server:main: Started @3797ms
Emulated network latency: 100ms
java.lang.NullPointerException
    at anywheresoftware.b4j.object.WebSocketModule$Adapter.onWebSocketText(WebSocketModule.java:121)
    at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextMessage(JettyListenerEventDriver.java:189)
    at org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69)
    at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:66)
    at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextFrame(JettyListenerEventDriver.java:158)
    at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:162)
    at org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:476)
    at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:220)
    at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:220)
    at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:245)
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:560)
    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.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.produce(EatWhatYouKill.java:132)
    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.lang.Thread.run(Thread.java:748)
INI
WebSoc Connected
OUT> <zal>
WS discon
DISCONNECT
INI
WebSoc Connected
ZAL
response
OUT> <zal>
>: BF_PPL in(MyMap) {TRNR=1000000682445986, pol=TRck}
MK> 1000000682445986 
DownloadApple
How to handle this error - I mean what can be a reason?
 

ajk

Active Member
Licensed User
Workflow is like below:

B4X:
in WebSocketHandler class
Sub Class_Globals
    Public ws As WebSocket
    .....
    
Sub Initialize (vCallback As Object, vEventName As String)
    ws.Initialize("ws")
    .....
    
Sub Connect(Url As String)
    ws.Connect(Url)
    .....
    
then called from Main: ws as WebSocketHandler =>  initialize & connect
When ws_Connected fired: callback to Main
then from Main: WS.SendEventToServer("TrigThis_OnServer", data)

Public Sub SendEventToServer(Event As String, Data As Map)
    Dim m As Map
    m.Initialize
    m.Put("type", "event")
    m.Put("event", Event)
    m.Put("params", Data)
    Dim jg As JSONGenerator
    jg.Initialize(m)
    ws.SendText(jg.ToString)
End Sub
 
Top