|Welcome to the Monastery|
CGI::Carp fatalsToFileby Bod (Curate)
|on Oct 05, 2021 at 17:14 UTC||Need Help??|
Bod has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for some debugging help please
I have what appears to be the same issue on two different websites. They are both on the same shared hosting but otherwise totally independent.
The most critical issue is with a script that gets booking information from OTAs, Online Travel Agents (Airbnb, Booking.com, etc) using their API to provide an ICS file. Our booking platform checks this information as well as our own booking database to show customers our availability. Our script caches the ICS file for 30 minutes. This script has an API that our booking platform calls to get a simple text file which lists the property number and either 'available' or 'booked'. When a customer commits to book, the API is called again but with a force parameter to bypass the cache.
Except the API returns a 500 error when called from the booking platform. But I cannot replicate it when calling the script using a web browser.
Here's the code we had working. I know there are some bad practices in there but this is legacy code and will get improved in due course. The important thing is that is was working fine until recently and I am not aware of anything that could have caused the change:
The &get is from LWP::Simple.
To try and understand what was going on, I changed the code to this:
and found that $availability was empty.
This shows that the response code is 500.
Copying the printed URL into a web browser gives the text output that I would expect.
I have checked the error logs provided to me by cPanel and nothing shows up at all.
Any ideas why a script would return a 500 error when called by LWP::Simple get but not when called by Chrome?
I have a similar, but intermittent problem on another site. This time the script is called from the browser using the fetch API. The script returns a JSON object. Again, the script returns a 500 error some of the time but works as predicted most of the time (unlike above which fails every time). Again I am at a loss how to debug this as I cannot catch the errors to find what or where they are.
If I had any hair, I would be pulling it out...