You are here:  » 504 gateway time-out with uidmap.php


504 gateway time-out with uidmap.php

Submitted by bigshopper on Wed, 2018-08-01 15:26 in

Hello,

I tried a lot of things, but if I load uidmap.php, the first time I get like 20-30 "step 1" lines (with product names). This takes a long time. The second and third time, I get a 504 gateway time-out. What to do? The file can be reached at:

{link saved}

Best Regards,

Robert

Submitted by support on Wed, 2018-08-01 15:38

Hello Robert and welcome to the forum!

uidmap.php, depending on database size, can run for several minutes and is not really intended to be requested over HTTP. The script does issue set_time_limit(0) which should enable the web server's PHP interpreter to run for as long as required (e.g. Apache/mod_php) but this doesn't mean that a proxy server inline between your connection and the web server won't time-out the connection - which in the case of a 504 gateway time-out is most likely to be the case here.

The Automatic Product Mapping by Unique ID page shows how to run uidmap.php after cron.php once you automate your site but to run uidmap.php on its own, you would really need to do this from the command line (for example over SSH using a client such as PuTTY) and then you can run the script by changing directory to the scripts folder e.g.

cd public_html/scripts/

And then running uidmap.php:

php uidmap.php

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by bigshopper on Wed, 2018-08-01 16:44

Hi David,

Thank you for your fast reply! Its an amazing script you offer, compliments! Thanks, I added lines to the cronjobs so then it should be correct tomorrow!

Best Regards,

Robert

Submitted by bigshopper on Thu, 2018-08-02 11:43

Hi David,

I discussed this topic with our developer, we use Plesk and in Plesk I have to select a file for the cronjob. If I execute the cronjob immediately, this error will popup:

{code saved}

He changed this file, but then still there are again includes in common.php. How to solve this?

I hope you can help!

Best Regards,

Robert

Submitted by support on Thu, 2018-08-02 11:53

Hi Robert,

The errors are due to PHP not being able to locate the include files, which will be because the script isn't being executed from the same directory as the script (since the include paths are relative).

If you're only able to enter the absolute path to a .php script per cronjob, then what you can do is add a chdir() call at the top of the scripts, so at the very top of scripts/cron.php and scripts/uidmap.php add this line just after the opening php tag:

  chdir("/var/www/vhosts/example.com/httpdocs/scripts/");

(replace example.com with your host name)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by bigshopper on Thu, 2018-08-02 11:58

Hi David,

Thanks for your super fast reaction! I just changed it and get now a new error:

chdir("/var/www/vhosts/example.com/httpdocs/scripts/");
Working...

{code saved}

What to do?

Thanks in advance!

Robert

Submitted by support on Thu, 2018-08-02 12:05

Hi Robert,

As the chdir() function was actually output as text I think it will have been inserted before the opening php tag (so it actually needs to be on line 2) - top of the script should be like this:

<?php
  chdir("/var/www/vhosts/example.com/httpdocs/scripts/");
  ... rest of script ...

(with your host name of course)

Regarding your second email; you may have been looking at your user level var/ folder rather than the top level - as that was output in the PHP error message it should be the correct path...

Cheers,
David.
--
PriceTapestry.com

Submitted by bigshopper on Thu, 2018-08-02 12:16

Hi David,

Super!!! It seems to be working (it's busy for a while now). Thank you very much!

Robert

Submitted by bigshopper on Thu, 2018-08-02 14:33

One more question about this. It seems to be working, but the script is now running for around 2 hours and still busy. I added around 430.000 products. How long should this take?

Submitted by bigshopper on Thu, 2018-08-02 14:49

The problem was that I was logged out in Plesk, that's why I didn't see the task was finished. It was finished, but the cronjob gave now this error/warning and I don't see my products combined based on EAN:

PHP Warning: Cannot modify header information - headers already sent by (output started at {code saved}uidmap.php on line 3 PHP Warning: Empty row packet body in {code saved}uidmap.php on line 33 PHP Warning: Error while sending QUERY packet.

Submitted by support on Thu, 2018-08-02 15:09

Hello Robert,

That sounds like the mysterious "MySQL server has gone away" error which can occur during long running operations against unbuffered queries. Please could you email me the modified (as per previous posts) scripts/uidmap.php that you are running and i'll a couple of mitigations that should help...

Cheers,
David.
--
PriceTapestry.com