B4J Question org.eclipse.jetty.io.EofException

woniol

Active Member
Licensed User
Longtime User
I use web socket lib in my b4J server app.
Sometimes i get:
B4X:
java.lang.RuntimeException: org.eclipse.jetty.io.EofException
I connect to my server from B4A app using websocket lib.

As i figure out it is thrown when client disconects while serwer sends data to.
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/io/EofException.html
Is there a way to catch this exception?

Here is the code i use:
B4X:
For i=0 To ActiveConnections.Size-1
            Dim wsc As WSController
            wsc = ActiveConnections.GetValueAt(i)
            If wsc<>Null Then
                wsc.ws.RunFunction(command, params)
                wsc.ws.Flush
            End If
        Next
 

Daestrum

Well-Known Member
Licensed User
Longtime User
put the code in a 'Try - Catch' construct
B4X:
Try
   BadCodeThatCausesExceptionHere
Catch
   log(LastException.Message)
End Try
 
Upvote 0

woniol

Active Member
Licensed User
Longtime User
That's what i do, I use the exact code from PushB4A module:
B4X:
Private Sub WebSocket_Disconnected
    If id <> "" Then CallSubDelayed3(WSShared, "RemoveConnection", id, Me)
End Sub
end
B4X:
Public Sub RemoveConnection(Id As String, pb As WSController)
    If pb <> ActiveConnections.Get(Id) Then Return 'this can happen if there was a "phantom" connection
    ActiveConnections.Remove(Id)
End Sub

Maybe WebSocket_Disconnected is not called for some reason, or client disconects while serverd is sendind data.
 
Upvote 0

woniol

Active Member
Licensed User
Longtime User
For now i'm testing it with Try / Catch.
I takes some time to reproduce this problem.

I'll try I will try srvr.CreateThreadSafeMap for ActiveConnections if it doesn't help.

Thanks
 
Last edited:
Upvote 0
Top