V
V
Vladislav Verbitsky2022-03-15 16:41:00
Google
Vladislav Verbitsky, 2022-03-15 16:41:00

How to make a latancy request to google?

How to check ping from service to google (latancy request)? "/latency [GET] - returns the delay from the service to google.com" - this is how it is written in the TOR.
Here is an option, but it does not work ... I register through a regular button on html, on a live server.
<button onclick="latency()">TOK</button>

async function latency(req, res) {
        try {
          exec('ping google.com', { encoding: 'binary' }, (err, stdout, stderr) => {
            if (err) {
              throw err;
            }
 
            const convert = iconv.decode(stdout, 'cp866'); /// Для рекода на русский
    
            res.status(200).json(`${convert.match(/Среднее.=.\d+/)[0]}мс`);
          });
        } catch (e) {
          res.status(400).json({ message: e.message });
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question