Android Question Weird websocket issue

techknight

Well-Known Member
Licensed User
Longtime User
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:

B4X:
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:
B4X:
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.
 

techknight

Well-Known Member
Licensed User
Longtime User
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
Top