HTTPRequest has a long delay

Godot Version



HTTPRequest is taking upwards of 30 seconds to initiate a request. I can monitor the http access log and see that the request doesn’t even reach the server until 30 seconds after initiating the request in Godot.

func version_check():

func _on_request_completed(result, response_code, headers, body):
> 200

curl will return a response in milliseconds

curl "" -s -o /dev/null -w "%{time_total}"
> 0.394262

Anybody have an idea on what is causing this latency? I’m not sure how to debug and see what HTTPRequest is doing, but Godot seems to be stalling on something before sending the request.

Is the version_check method running at the time you’re expecting it to run? Just to make sure that it’s the HTTP request itself that takes long to start and not some other part that runs before the request.

Aside from that, two things come to mind but neither is comfy to do. One is to install Wireshark and examine the outgoing traffic and hope it reveals something. The other is to check Godot source code if there’s something going on that might cause this.

Most of the possible network-level issues ( like DNS resolution ) are eliminated by curl running in a reasonable timeframe imo.

Thanks for the suggestions. Yes, I also should have confirmed that version_check is called when expected, the delay isn’t introduced somewhere else in the surrounding logic.

I think I have narrowed down the issue to an IPv6 misconfiguration on the server.

curl --ipv6 ""
> curl: (28) Failed to connect to port 443 after 75008 ms: Couldn't connect to server

I suspect that Godot is attempting an IPv6 connection by default, then times out after 30 seconds, then makes a second attempt with IPv4, which then succeeds.

I’m not sure if I could force Godot to prioritize IPv4 over IPv6. But I’m going to shift focus on fixing IPv6 on the server, since that needs to be fixed anyway. That should resolve this issue.

1 Like

You might be able to do it by resolving the IP address of the domain with IP.resolve_hostname forcing IPv4, and then pass that to the request. To be sure, override the Host header to the original domain, so the server knows which host you’re accessing behind that IP address.

1 Like

I wanted to confirm that misconfigured IPv6 on the server was indeed the problem. The delay in Godot went away entirely after IPv6 was fixed.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.