Facepunch / garrysmod-issues

Garry's Mod issue tracker
144 stars 56 forks source link

HTTP Fetch/Post functions now take ~4x longer to send #5574

Open marchc1 opened 1 year ago

marchc1 commented 1 year ago

I realized last night that my http.Fetch/Post response times were elevated with a recent update. It seems like this problem comes from the recent fix to block local HTTP requests by doing a DNS query before every request.

But this has seemed to add significant amounts of latency to every single request. Before this update, I got similar latency increases, but only if I had not used that URL during that game session or if I hadn't used it in a while (guessing due to a DNS query). Now it happens every single request.

The latency increases are significant, too; previously I was able to get ~30ms response times from my server, but now I get nearly 110ms response times. One of my friends, who lives on the other side of the continent from my server, used to get ~100ms and now gets 400ms response times. I also tried the same test on a HTTP GET echo server, which had 80ms with browser and 300ms with gmod. One of my projects requires semi-quick response times (100ms pushes it but is acceptable), and this really messes with it.

This was all done client-side, but I did tests on the server and verified it happened there too.

To replicate, run this a few times in Garry's Mod:

local start = SysTime()
http.Fetch("https://httpbin.org/get", function()
    print((SysTime() - start) * 1000)
end)

and then run this a few times in a browser:

var start = new Date()
fetch("https://httpbin.org/get", {method: "GET"}).then((response) => {
    var end = new Date()
    console.log((end - start))
})
robotboy655 commented 1 year ago

Should be better on dev.

marchc1 commented 1 year ago

Tested, latency is back to normal now, thank you!

marchc1 commented 1 year ago

@robotboy655 Can this issue be re-opened, since the patch had to be reverted?