techknight Well-Known Member Licensed User Longtime User Mar 26, 2018 #1 I am using code based off of the tutorial/example, using B4J as a websocket server, and Android as a websocket client. Everything works fine, the server sends data to the Android client via a timer and I have no issues there. But sometimes 15 minutes in, up to 45 minutes out, the websocket will randomly drop, and then the wsh_Closed event fires on the Android client. So I turned off the Logcat filtering, and I keep getting this from Android when it happens: Code: Copy run() : SocketException (java.net.SocketException: Connection reset) ended fail connection [code = 3, reason = WebSockets connection lost quit ended java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected) On B4J, I get this in red: Code: Copy onWebSocketError: null any thoughts? Its not a WiFi or device related issue, I have tried another device, they arnt doing to sleep. it just drops.
I am using code based off of the tutorial/example, using B4J as a websocket server, and Android as a websocket client. Everything works fine, the server sends data to the Android client via a timer and I have no issues there. But sometimes 15 minutes in, up to 45 minutes out, the websocket will randomly drop, and then the wsh_Closed event fires on the Android client. So I turned off the Logcat filtering, and I keep getting this from Android when it happens: Code: Copy run() : SocketException (java.net.SocketException: Connection reset) ended fail connection [code = 3, reason = WebSockets connection lost quit ended java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected) On B4J, I get this in red: Code: Copy onWebSocketError: null any thoughts? Its not a WiFi or device related issue, I have tried another device, they arnt doing to sleep. it just drops.
Erel B4X founder Staff member Licensed User Longtime User Mar 27, 2018 #2 You should assume that the connection will break from time to time. Sleep for a few seconds and try to connect again. Upvote 0
You should assume that the connection will break from time to time. Sleep for a few seconds and try to connect again.
techknight Well-Known Member Licensed User Longtime User Mar 28, 2018 #3 I should assume, but every 10 to 15 minutes? on the local LAN? Sure the frequency could vary between 10 to 45 minutes or so but it seems to err on the side of 10 to 15 minutes. That just seems off especially on the local LAN. If I use ABMaterial's websocket it seems to never drop. So looks like I need to investigate what he does to keep the socket active. I wonder if I need a 2-way ping? Upvote 0
I should assume, but every 10 to 15 minutes? on the local LAN? Sure the frequency could vary between 10 to 45 minutes or so but it seems to err on the side of 10 to 15 minutes. That just seems off especially on the local LAN. If I use ABMaterial's websocket it seems to never drop. So looks like I need to investigate what he does to keep the socket active. I wonder if I need a 2-way ping?
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2018 #4 Check this example: Custom WebSocket Based Push Framework It does everything possible to keep an always active connection. Upvote 0
Check this example: Custom WebSocket Based Push Framework It does everything possible to keep an always active connection.