« Previous Next »

Not Answered Thread: HTTP Error 502.2 - Bad Gateway - Please Help

Last post 02-06-2009 8:45 AM by nishal. 7 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (8 items)

Sort Posts:

  • 01-08-2009, 7:49 AM

    • nishal
    • Not Ranked
    • Joined on 01-08-2009, 5:52 AM
    • Posts 4

    HTTP Error 502.2 - Bad Gateway - Please Help

     Hi

     I am relatively new to web development and I am in need of some assistance with regard to setting up a CGI application on IIS7. 

    I have managed to set up the Delphi GCI application to successfully run on both Windows 2000 and XP environments, but am unable to do so on Vista (home premium). I recieve the following error message :

     

    HTTP Error 502.2 - Bad Gateway

    The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "".

    Detailed Error InformationModule CgiModule
    Notification ExecuteRequestHandler
    Handler CGI-exe
    Error Code 0xc0000005

    Requested URL http://localhost:80/veda/veda.exe
    Physical Path C:\cgi\veda.exe
    Logon Method Anonymous
    Logon User Anonymous 

    I have tried to set up the application on Vista as closely as possible to the manner in which I have done on the other 2 operating systems but without any success.

    Any assistance would be much appreciated.

    Regards

    Nishal

     

     


  • 01-08-2009, 9:14 AM In reply to

    Re: HTTP Error 502.2 - Bad Gateway - Please Help

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 01-09-2009, 6:34 AM In reply to

    • nishal
    • Not Ranked
    • Joined on 01-08-2009, 5:52 AM
    • Posts 4

    Re: HTTP Error 502.2 - Bad Gateway - Please Help

    Hi Jeff

    Thank you for your quick response. As I do not have the source code for the application I am having trouble with, I created another simple delphi cgi application that just displays a string in the web browser and it runs successfully in XP and Windows 2000.  But it doesn't work in Vista. I get the same error as before. Is there any setting in IIS7 that I might have possibly missed? What would cause the application not to return any http headers in IIS7 but successfully do so in previous versions of IIS?

    Thanks again for your help

    Nishal 

     

     

     

  • 01-14-2009, 8:33 PM In reply to

    Re: HTTP Error 502.2 - Bad Gateway - Please Help

    Hi,

    Please check if you have used STD_INPUT_HANDLE without check for 0 content length.

    IIS7.0 expects the content length when we try to use STD_INPUT_HANDLE. Calling GetStdHandle(STD_INPUT_HANDLE) for a request which does not have a Content-Length/Entity body will cause GetStdHandle(STD_INPUT_HANDLE) to hang on IIS 7.0. Then, the same error message to yours will be returned.

    If problem still persists ,please update here.

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 01-23-2009, 6:15 AM In reply to

    Re: HTTP Error 502.2 - Bad Gateway - Please Help

     I too am facing the same problem. Did it get resolved?

  • 01-26-2009, 6:43 AM In reply to

    • nishal
    • Not Ranked
    • Joined on 01-08-2009, 5:52 AM
    • Posts 4

    Re: HTTP Error 502.2 - Bad Gateway - Please Help

    The application uses "TTextRec(Input).Handle" for a request (CGIHTTP). I tried replacing this with "GetStdHandle(STD_INPUT_HANDLE)" but still get the same error.

    I also tried commenting out "Reset(Input);" line in the CGIApp, but it doesn't help either.

  • 02-01-2009, 4:40 AM In reply to

    • Rona
    • Not Ranked
    • Joined on 02-01-2009, 9:22 AM
    • Posts 1

    Re: HTTP Error 502.2 - Bad Gateway - Please Help

    Hi Nishal

    There was a similar problem with IIS6 (XP and Windows Server 2003) and Delphi6, which some wonderful person solved with a fix to SysUtils.pas. I am now using Turbo Delphi, and have just tried the Delphi 6 fix which caused Turbo Delphi to crash with 'Error in recursing to variants'. This is totally beyond me, as I am just a simple application programmer, and have never delved into the depths of Delphi source code. I am currently tempted to go back to Delphi 6 (plus the fix to sysutils.pas) as I know it works.

    The clue (I think) is in the message: "The headers it did return are '' ", and the kind suggestion about the length of StdInput by the person above.

    Like you, I have a very simple test program, with only one statement

      Response.content := '<html>Hello from Rona</html>';

    I think maybe Turbo Delphi is not putting the length of this string into the HTTP header properly, but I am not sure if you can do this easily yourself. It may be something to do with strings and PChars, which often cause mysterious problems. Which version of Delphi are you using?

    Regards, and waiting hopefully that someone out there has solved this!!!

    Rona

  • 02-06-2009, 8:45 AM In reply to

    • nishal
    • Not Ranked
    • Joined on 01-08-2009, 5:52 AM
    • Posts 4

    Re: HTTP Error 502.2 - Bad Gateway - Please Help

    Sorry for not responding sooner,have been busy with other projects.

    I am using Delphi 6. Can you tell me where I can get the patch you mentioned Rona?

    I have also tried changing the GetEnvironmentVariable function in the SysUtils but still no luck. 

Page 1 of 1 (8 items)
Microsoft Communities