B4J Question AsyncStreams & client is turned off

tchart

Well-Known Member
Licensed User
Longtime User
I'm developing an app that uses ServerSocket and AsyncStreams.

If my client terminates the stream I get the _Terminated message.

If I turn the client off (ie power device off) I don't get any messages so I dont know that the astream has been terminated.

Is there any way to dtermine if the astream is still connected? Or do I just need to keep track of and manually check the last time data was received?

Thanks
 

tchart

Well-Known Member
Licensed User
Longtime User
For now Im just checking if a previous stream exists when the client reconnects. If there is a previous connection I terminate it.
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Erel, the client is a UDP/Network device. It creates a socket connection to the nominated server. I was just concerned if the client gets disconnected abruptly and then reconnects with a new socket. I've added code to check if there was a previous connection for the client MAC address which seems to work well to keep connections down.

The problem is that I have a REST API which writes data to the socket. If the client has disconnected I dont know if the write was successful or not. I probably need to do more testing around this to see if the write fails.

This is the device;
http://www.limitlessled.com/shop/wifi-udp-receiver-bridge/
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Erel, I have done more testing and although astream.Write returns true it does timeout and I get this error which I am now releasing the stream;

Exception=(SocketTimeoutException) java.net.SocketTimeoutException: Read timed out

Is there a way to adjust the socket timeout?
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Erel, no code as such.

After I call astream.Write (which returns true) there is a delay (timeout period?) and then Astream_Error is called.
 
Upvote 0
Top