Java – network quality metrics on webapp
Is there any way to indicate the current network quality of the client on the web application (some type of bar, similar to the N / W quality bar on the mobile phone)?
One of our web applications handles data transmission. Most of the transmission fails due to the network problems of the client. They obviously don't understand it Clients report failure, and the actual problem is their n / W connection. I'm looking for a way to point out the same content to them when they use the application (in my web application)
I know there are other tools to investigate, but layman users don't have them (at least our users)
thank you.
Solution
One way is to use window navigator. Online for example:
if (navigator.onLine) { alert('online') } else { alert('offline'); }
Or capture changes:
window.addEventListener("offline",function(e) { alert("offline"); },false); window.addEventListener("online",function(e) { alert("online"); },false);
You can average over a specific time interval and develop algorithms to quantify connectivity as 10%, 50%, etc
You can also set Ajax voting and observe timeout, but be careful not to increase traffic too much:
$.ajax({ type: "GET",url: "yourserver.com",success: function(data){ alert("Connection active!") } error: function(XMLHttpRequest,textStatus,errorThrown) { if(textStatus == 'timeout') { alert('Connection seems dead!'); } } });