woniol Active Member Licensed User Longtime User Sep 12, 2014 #1 I use web socket lib in my b4J server app. Sometimes i get: Code: 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: Code: 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
I use web socket lib in my b4J server app. Sometimes i get: Code: 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: Code: 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 Expert Licensed User Longtime User Sep 12, 2014 #2 put the code in a 'Try - Catch' construct Code: Try BadCodeThatCausesExceptionHere Catch log(LastException.Message) End Try Upvote 0
put the code in a 'Try - Catch' construct Code: Try BadCodeThatCausesExceptionHere Catch log(LastException.Message) End Try
Erel B4X founder Staff member Licensed User Longtime User Sep 14, 2014 #4 Seems like you are not updating ActionConnections map when the connection is broken. See PushB4A module from the server example. Upvote 0
Seems like you are not updating ActionConnections map when the connection is broken. See PushB4A module from the server example.
woniol Active Member Licensed User Longtime User Sep 14, 2014 #5 That's what i do, I use the exact code from PushB4A module: Code: Private Sub WebSocket_Disconnected If id <> "" Then CallSubDelayed3(WSShared, "RemoveConnection", id, Me) End Sub end Code: 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
That's what i do, I use the exact code from PushB4A module: Code: Private Sub WebSocket_Disconnected If id <> "" Then CallSubDelayed3(WSShared, "RemoveConnection", id, Me) End Sub end Code: 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.
Erel B4X founder Staff member Licensed User Longtime User Sep 14, 2014 #6 I don't know if it is related or not however it seems like you haven't created a thread safe map for ActiveConnections. This can also cause problems. The Try / Catch solution is a good solution in this case as it is indeed possible that the connection was broken and the server doesn't yet know the correct status. Upvote 0
I don't know if it is related or not however it seems like you haven't created a thread safe map for ActiveConnections. This can also cause problems. The Try / Catch solution is a good solution in this case as it is indeed possible that the connection was broken and the server doesn't yet know the correct status.
woniol Active Member Licensed User Longtime User Sep 14, 2014 #7 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: Sep 14, 2014 Upvote 0
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