0
votes

502 - Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

I am working Headless Browser that is ChromiumWebBrowser thats work fine on local machine and when we publish code on Azure App Service this gives us above mentioned error. Currently we use Shared infastructured (Free version for Testing).

region ChromiumWebBrowser

        var browser = new ChromiumWebBrowser(url);

        await LoadPageAsync(browser);

        var result = browser.GetBrowser().MainFrame.GetSourceAsync().Result;

        browser.Stop();
        if (!browser.IsDisposed)
            browser.Dispose();

        #endregion
1

1 Answers

0
votes

Thanks for asking question! Just to confirm if you are using GDI? As working with headless browser that is ChromiumWebBrowser mostly requires GDI support and Azure App Services on Windows, conflicts with Win32k.sys (User32/GDI32) Restrictions, As mentioned,

For the sake of radical attack surface area reduction, the sandbox prevents almost all of the Win32k.sys APIs from being called, which practically means that most of User32/GDI32 system calls are blocked. For most applications this is not an issue since most Azure Web Apps do not require access to Windows UI functionality (they are web applications after all). However one common pattern that is affected is PDF file generation. There are several cases of note:

Suggest you check this discussion on Chrome driver is not working on azure web apps