Http.request takes an unreasonably long time

Hey Defolder,
I’m experiencing some weirdness where http.request on any url called at init will require at least 6 or 7 seconds before calling the callback.
I am not on a slow network.
I get messages in Defold console like this:

WARNING:DLIB: Profiler Message.Dispatch @__http_worker_0 took 3.804 seconds
ERROR:DLIB: mbedtls_ssl_handshake failed: MBEDTLS_ERR_NET_CONN_RESET - -80 (-0x0050)
WARNING:SCRIPT: Failed to return http-response. Requester deleted?

I’ve tried to my own local server, to google, etc but there seems to be some weird lag. I’ve also tried stripping down the active calls but the delay persists.
Any suggestions? Am I running an outdated version of http or something?
Thanks,
grify

P.S. I’ve tried fetching extremely simple and short text strings from my boiletplate http server and while the data loads almost immediately (less than 1 second) in browser, it always takes an extra ~6 seconds on defold.

What if you try on a different network (use your phone as a hotspot for instance)?

It could be a firewall issue. Or antivirus. Or DNS. Or SSL handshake.

As in running on the same machine?

I’ve confirmed that the problem isn’t on the WiFi, as on my hotspot I get this:

INFO:DLIB: SSDP: Started on address 172.20.10.7
DEBUG:SCRIPT: request sent at 0.319642
WARNING:DLIB: Profiler Message.Dispatch @__http_worker_0 took 2.808 seconds
DEBUG:SCRIPT: received at 0.596155
DEBUG:SCRIPT: 200
WARNING:DLIB: Profiler TimerWorld.Update took 2.544 seconds

and those times are os.clock(). http.request is called only once, in init.
To be clear, this always loads within a second on browser.

Ok, and what if you do an http request to an IP address instead of a domain name? If it’s still slow then we can rule out DNS.

Strangely enough, I can’t find any non-localhost IPs to use that return anything, could you provide one?

http://45.33.34.207/

Here’s one of mine, should return a timestamp

1 Like

Thank you. Very strange because with restarting neither Defold nor my computer, and not even using my computer whatsoever from last morning to this one, the lag seems gone. Same WiFi, same project, same code, same instance of Defold, same environment, and same cat by my side, it just works now. I’m running alternate tests enabling and disabling components but it seems like even with everything enabled, the request-response time has inexplicable dropped from 6 seconds to 0.2 seconds. I’ll finish my tests and keep working as normal but keep this post open a bit longer in case it recurs.
Thanks for your help Pkeod and Britzl, I really appreciate it.
Have a nice day!
grify

1 Like