Using OECGI to generate web pages can sometimes result in the web server returning gateway errors like in the images below:
This article is to share the experience and solutions I've come across when dealing with OECGI gateway errors.
Types of Gateway Errors
Depending on the web server the error response could be HTTP 500 Gateway Error or 502.2 Bad Gateway. Earlier versions of IIS returned 500 Gateway Error while later versions like IIS 8.5 included in Windows 8 and Server 2012 return 502.2 Gateway Error. So if you're looking for a solution but the errors aren't exactly matching your error code it could be due to a difference in the web server even though the same error is present.
Failure To Debug
When debugging O4W or INET BASIC+ programs using a debug statement and the oengine running on the server desktop the debug window might never appear and a gateway error could be returned to the browser. Check the server's OECGI registry settings and ensure the StartUp flags key is set to 1.
Out of the box the default StartUp flag is 65 which doesn't allow the engines to appear even though OEngine server is being run in debug mode. This will cause a gateway error when the debug statement is reached because the debugger window cannot load so the whole request terminates.
OECGI3 POST Failure
When working with OECGI3.exe to post custom data a Gateway Error can be returned with the uploade size exceeds apporximately 249 bytes of non-form encoded data. OECGI3.exe was designed to handle form encoded POST requests and sending non-form encoded POST requests will fail once the request reaches a certain size. You can resolve this gateway error by only making POST requests to OECGI3.EXE with form encoded payloads or switching to OECGI4.exe