502 Bad Gateway error returned by one of the webservices

502 Bad Gateway error returned by one of the webservices

by Mustafa Hajjar -
Number of replies: 2

Hi there;

One of my webservices is returning 502. It's a new webservice and it was installed part of a new plugin after upgrading the server from 3.8.3+ to 3.11.3+ (php7.4/Ubuntu/nginx1.7).

The webservice works fine in the development environment (Macbook pro MAMP 3.11.3+) and staging (Win2016 server XAMP installation).  I looked in the php.log on the server but there are no errors there just bunch of unrelated NOTICE messages.

I found a similar post (https://moodle.org/mod/forum/discuss.php?d=225495), but it wasn't related to the error I'm having.  I tested on Chrome, Safari, and Edge but the error was on all 3!

The service itself doesn't do anything special, it returns $data from an exporter bookings->export($renderer);

Any ideas?

Thanks,

Mustafa

Average of ratings: -
In reply to Mustafa Hajjar

Re: 502 Bad Gateway error returned by one of the webservices

by Ken Task -
Picture of Particularly helpful Moodlers

Probably best to have a development environment in the same environment as 'staging' or 'production' rather than having/using MAMP ... cause MAMP is local ... there is no or localhost networking involved ... MAMP would be using localhost ... any other setup - true networking.

The error 502 ...

A 502 Bad Gateway Error means that the web server you've connected to is acting as a proxy for relaying information from another server, but it has gotten a bad response from that other server. ... It's possible the server is overloaded or there are network issues between the two servers, and it's just a temporary problem.


"It's a new webservice"

"The service itself doesn't do anything special, it returns $data from an exporter bookings->export($renderer)"

Looks like a 'booking' plugin, so which:
https://moodle.org/plugins/mod_booking - shows compatible up to 3.7
https://moodle.org/plugins/mod_reservation - shows compatible up to 3.9
or is it another 'booking'?

In a page that talks about 502 errors and how to fix, it suggest these:

How to Fix 502 Bad Gateway Error
    1. Refresh the Page
    2. Clear Browser Cache
    3. Try in Incognito Mode
    4. Flush DNS
    5. Test on Another Device
    6. Check Error Log
    7. Check Plugins and Themes
    8. Check CDNs
    9. Check the Site Status
    10. PHP max_execution_time and max_input_time

Sorry ... don't have a solution for ya ... just info and places to look!

'SoS', Ken

In reply to Ken Task

Re: 502 Bad Gateway error returned by one of the webservices

by Mustafa Hajjar -
Thanks for the reply Ken; that is very insightful. I will look into reconfiguring dev & test/staging, and ask around if there's any proxying going on.

The webservice is part of a new homegrown instructor/student session booking plugin for student pilots.

The "How to" seems to be focused on the client side, and I did use different browsers on different machines as I mentioned, but I'll give it a go anyway on each of the machines. Is there any other error log I should check apart from the php log?

I tried to increase the max_execution_time to 5000ms in my repository.js call to the webservice just to test "return Ajax.call([request], true, true, false, 5000)[0];", but that didn't fix the problem either.  The weird thing is that all other webservices in the plugin are working fine, that's why I am wondering if there is something specific to this webservice.

I will ask for the webserver to be restarted, I saw from a previous post, it solved the problem but that was from 2013, a lot has changed since then.

Thanks again,
Mustafa