tchart Well-Known Member Licensed User Longtime User May 22, 2016 #1 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
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 May 23, 2016 #2 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
For now Im just checking if a previous stream exists when the client reconnects. If there is a previous connection I terminate it.
Erel B4X founder Staff member Licensed User Longtime User May 23, 2016 #3 You should also handle the Error event. Upvote 0
tchart Well-Known Member Licensed User Longtime User May 23, 2016 #4 Erel said: You should also handle the Error event. Click to expand... Thanks Erel, I am handling the Error event but if the client disconnected abruptly I get no events firing. Upvote 0
Erel said: You should also handle the Error event. Click to expand... Thanks Erel, I am handling the Error event but if the client disconnected abruptly I get no events firing.
Erel B4X founder Staff member Licensed User Longtime User May 23, 2016 #5 This means that the network driver "thinks" that it is still connected. The solution for such cases is to use a timer and send a ping request every few seconds. If there is no response then the connection is broken. With that said, there are simpler and better solutions. What is the client? How is it implemented? Upvote 0
This means that the network driver "thinks" that it is still connected. The solution for such cases is to use a timer and send a ping request every few seconds. If there is no response then the connection is broken. With that said, there are simpler and better solutions. What is the client? How is it implemented?
tchart Well-Known Member Licensed User Longtime User May 24, 2016 #6 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
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/
tchart Well-Known Member Licensed User Longtime User May 24, 2016 #7 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
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?
Erel B4X founder Staff member Licensed User Longtime User May 24, 2016 #8 The value returned from astream.Write is not relevant. It just means that the queue is not full. Which code causes this error? Do you see it in Astream_Error sub? Upvote 0
The value returned from astream.Write is not relevant. It just means that the queue is not full. Which code causes this error? Do you see it in Astream_Error sub?
tchart Well-Known Member Licensed User Longtime User May 25, 2016 #9 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
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.
Erel B4X founder Staff member Licensed User Longtime User May 25, 2016 #10 This delay is not configurable. It is the time that takes the driver to find out that the connection is no longer valid. Upvote 0
This delay is not configurable. It is the time that takes the driver to find out that the connection is no longer valid.