Good day all, Please I have this code below for testing download speed, and has been working for some time now. But recently always bring this error and doesn't work any more. Please help look into it.
Thanks
Tried with this url: 'https://drive.google.com/open?id=1MBHJXeRxMLLwHFpqbgTdEPsFArMM0cz7'
[Error: Unable to resolve host "drive.google.com": No address associated with hostname]
Tried with this url: 'https://upload.wikimedia.org/wikipedia/commons/b/b9/Pizigani_1367_Chart_1MB.jpg'
[Error: Unable to resolve host "upload.wikimedia.org": No address associated with hostname]
const downloadSizeInBits = 12000000;
const metric = 'MBps';
export const measureConnectionSpeed = (imageURIParam: string): any => {
const imageURI = imageURIParam
? imageURIParam
: 'https://drive.google.com/open?id=1MBHJXeRxMLLwHFpqbgTdEPsFArMM0cz7';
return new Promise((resolve, reject) => {
const startTime = new Date().getTime();
RNFetchBlob.config({
fileCache: false,
})
.fetch('GET', imageURI, {})
.then((res) => {
const endTime = new Date().getTime();
const duration = (endTime - startTime) / 1000;
const speed = downloadSizeInBits / (1024 * 1024 * duration);
resolve({metric, speed});
})
.catch(reject);
});
};
//Called from here in another component
getDownloadSpeed = async () => {
try {
const networkSpeed = await measureConnectionSpeed();
this.setState({value: networkSpeed.speed});
return networkSpeed.speed;
} catch (error) {
//handle error
ToastAndroid.show(
'Network Issues, unable to get download speed',
ToastAndroid.LONG,
);
console.log(error);
}
};
Thanks
Tim