html5_speedtest icon indicating copy to clipboard operation
html5_speedtest copied to clipboard

no error validations

Open mturnaviotov opened this issue 9 years ago • 4 comments

os software: -centos 7.2 (in openvz) -nginx 1.6.3 -php 5.4.16 with php-fpm

no download result checking.

in chrome console:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

500 xhr network.js:990

in nginx acces and ssl access logs "GET /network.php?module=download&size=0&network-1462870505927 HTTP/1.1" 500 5 "POST /network.php?module=upload&size=2097152&network-1462871045121 HTTP/1.1" 413 600

--- nginx error.log: "PHP Fatal error: Call to undefined function mb_strlen() in /var/www/speedtest/network.php"

client intended to send too large body: 2097152 bytes

in web browser:

It took less than 8 seconds to download 1342177280MB of data... Restarting with 2684354560MB! It took less than 8 seconds to download 2684354560MB of data... Restarting with 5368709120MB! It took less than 8 seconds to download 5368709120MB of data... Restarting with 10737418240MB! It took less than 8 seconds to download 10737418240MB of data... Restarting with 21474836480MB! It took less than 8 seconds to download 21474836480MB of data... Restarting with 42949672960MB! It took less than 8 seconds to download 42949672960MB of data... Restarting with 85899345920MB! It took less than 8 seconds to download 85899345920MB of data... Restarting with 171798691840MB! It took less than 8 seconds to download 171798691840MB of data... Restarting with 343597383680MB! It took less than 8 seconds to download 343597383680MB of data... Restarting with 687194767360MB! It took less than 8 seconds to download 687194767360MB of data... Restarting with 1374389534720MB! ... It took less than 8 seconds to download 7.555786372591432e+23MB of data... Restarting with 1.5111572745182865e+24MB! It took less than 8 seconds to download 1.5111572745182865e+24MB of data... Restarting with 3.022314549036573e+24MB!

Finished download, average: NaNMbps

mturnaviotov avatar May 10 '16 09:05 mturnaviotov

It seems that you have gzip compression enabled under nginx settings and since the speedtest library does rely on a single big text string in order to mesure throughput, the compression makes it inoperative.

Please consider using this example in your nginx configuration file:

server {
    gzip off;
    ...
}

If you can confirm this as a possible solution you can make a pull request on this file. https://github.com/enryIT/html5_speedtest/blob/master/network.php#l18

Here you can see I already disabled gzip by passing a new value for the apache environment variable "gzip", unfortunately I can't do the same with nginx as it doesn't support env variables.

enryIT avatar May 10 '16 19:05 enryIT

we fix it by php mbstring install, it can't install by default, so may be fix requirements list

mturnaviotov avatar May 15 '16 13:05 mturnaviotov

How can the multibyte extension solve the compression issue? Can you explain it or make a pull request on the README?

enryIT avatar May 15 '16 15:05 enryIT

With enabled Firebug download test succeeded but was pretty slow. So, I guessed there is a connection between speed and correct measurement.

I changed content sizes in network.php and it fixes the issue:

// Define a content size for the response, defaults to 20MB.
$contentSize = 200 * 1024 * 1024;

if (!empty($_GET['size'])) {
    $contentSize = intval($_GET['size']);
    $contentSize = min($contentSize, 2000 * 1024 * 1024); // Maximum value: 200MB
}

I´m on nginx with following config:

location / { gzip off; client_max_body_size 1100M; keepalive_timeout 0; add_header Cache-Control 'no-cache, no-store, no-transform'; add_header Pragma 'no-cache'; add_header Access-Control-Allow-Origin '*'; }

thomasbergmann avatar Sep 27 '16 18:09 thomasbergmann