Im developing a native android app , there are no errors but Logcat says
Caused by: java.net.ConnectException: failed to connect to some ip.
Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT
The warning line pointed by android - Studio :-
HttpResponse httpResponse = httpClient.execute(httpPost);
This issue occurs when your app is not able to communicate with your local server on LAN .
Can any one suggest me articles to handle this Exceptions efficently ? Just wanted my app to be free of errors and warnings .
May be we can use a try - catch
? Atleast , just to show a toast "Connection error" :)
Connectivity is one of those things that rely on various Real World™ coincidences, like being within range of a Wi-Fi hotspot, and your signal not being drowned by another Wi-Fi signal on the same channel. It is therefore guaranteed that at times, it will fail.
Since you say that "there are no errors", this means that the error is handled somewhere, somehow, perhaps in code that you have no control over. However, the fact that the error gets handled does not mean that there is no disruption in the communication. If you had a constant stream of data flowing between client and server, there would be a gap in the continuity of the data at that moment. The transmission may have been retried, and succeeded, but there was a delay. If you find delays, and you are troubleshooting them, you do want to know their cause. Therefore, these log messages are important.
So, you need to get used to them, and learn to ignore them until the time comes one day when you will be troubleshooting something connectivity related, at which point you will learn to also love them.
To conclude: "Connection error" toasts are not very helpful, because in a real-world usage scenario, they would be popping up all the time. Allowing the errors to be logged is probably the only thing you can do, and probably also the best.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments