user1419810
user1419810

Reputation: 846

504 gateway timeout - php

I'm calling an api using file_get_contents which is rather sporadic, sometime the call returns data really quickly (1-2 seconds) at other times takes a bit longer (30 seconds plus) leading to a 504 gateway timeout, here is the header return:

"Array ( [0] => HTTP/1.1 504 GATEWAY_TIMEOUT [1] => Content-Length: 0 [2] => Connection: Close )”

I've tried setting - set_time_limit(0); however this doesn't seem to have any effect, is there any other way to stop this timeout happening, i.e. wait longer to get a return from the api?

Cheers,

Matt

Upvotes: 0

Views: 10283

Answers (1)

Strahinja Djurić
Strahinja Djurić

Reputation: 404

Regarding 504 error, either is php taking too long to process the script or your database process large query. As discussed in comments, it seems like it is MySQL timeout.

What you gonna do is to increase timeout in my.cnf (which is MySQL configurational file) and change this line of code wait_timeout to some reasonable value, lets say 28000.

That should do it.

Upvotes: 4

Related Questions