apache / cordova-plugin-network-information

Apache Cordova Network Information Plugin
https://cordova.apache.org/
Apache License 2.0
464 stars 321 forks source link

How to detect latency or ping or can I detect connection if the device network is slow or fast? #70

Closed jayzyaj closed 5 years ago

janpio commented 6 years ago

My guess is that the only way to measure that is to make an actual request.

Note the time, make a request to a server endpoint that also returns the time, note the time when the response comes in - use all 3 measurement to do some calc for the roundtrip time. (Alternatively connect to any endpoint, do the calc with just 2 numbers)

bradiosd commented 6 years ago

The way I achieved this in our project (we are using Ionic 3.x by the way) was to check the API speed using a timer in an interceptor. Depending on how long the request lasts per request is our latency for that particular request lifecycle.

jcesarmobile commented 5 years ago

This is not possible with the plugin