Important network example:
[B4X] [B4XPages] Network + AsyncStreams + B4XSerializator
Assuming that everything is implemented correctly, there are cases where the network adapter doesn't recognize the state correctly. You can usually solve it in the application layer. Send a "ping" request every second and if there is no response after 10 seconds, break the connection.