I using CEFSharp WinForm to call website, but return blank page when using a Proxy server. If I turn off the proxy server setting, the website would be displayed. here is my code :
public ChromiumWebBrowser browser;
public Form1()
{
try
{
InitializeComponent();
InitBrowser();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString());
}
}
public void InitBrowser()
{
try
{
CefSettings cfsettings = new CefSettings();
//cfsettings.CefCommandLineArgs.Add("proxy-server", "200.29.191.149:3128");
CefSharpSettings.ShutdownOnExit = true;
//cfsettings.UserAgent = "My/Custom/User-Agent-AndStuff";
// CefSharpSettings.Proxy = new ProxyOptions(ip: "213.166.75.178", port: "9275", username: "W09s1H", password: "eMwmFL");
//cfsettings.DisableGpuAcceleration();
Cef.Initialize(cfsettings);
var rc1 = new RequestContext();
browser = new ChromiumWebBrowser("https://whatismycountry.com/");
panel1.Controls.Add(browser);
browser.Dock = DockStyle.Fill;
browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString());
}
}
private void Browser_IsBrowserInitializedChanged(object sender, EventArgs e)
{
if (((ChromiumWebBrowser)sender).IsBrowserInitialized)
{
dd1();
//if needed then use dev tool
//browser.ShowDevTools();
}
}
public async void dd1()
{
try
{
await SetProxy("91.188.241.26:9055");
//await SetProxy("W09s1H:eMwmFL@91.188.241.26:9055");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString());
}
}
public Task SetProxy(string address)
{
try {
return Cef.UIThreadTaskFactory.StartNew(() =>
{
var context = browser.GetBrowser().GetHost().RequestContext;
context.SetPreference("proxy", new Dictionary<string, object>
{
["mode"] = "fixed_servers",
["server"] = address
}, out _);
});
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString());
throw ex;
}
}
and this is debug.log
[0201/073227.893:ERROR:gl_surface_egl.cc(668)] EGL Driver message (Critical) eglInitialize: No available renderers.
[0201/073227.893:ERROR:gl_surface_egl.cc(1115)] eglInitialize D3D11 failed with error EGL_NOT_INITIALIZED, trying next display type
[0201/073228.905:ERROR:gl_surface_egl.cc(668)] EGL Driver message (Critical) eglInitialize: No available renderers.
[0201/073228.905:ERROR:gl_surface_egl.cc(1115)] eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED
[0201/073228.905:ERROR:gl_initializer_win.cc(196)] GLSurfaceEGL::InitializeOneOff failed.
[0201/073228.908:ERROR:viz_main_impl.cc(180)] Exiting GPU process due to errors during initialization
[0201/073228.933:WARNING:gpu_process_host.cc(1213)] The GPU process has crashed 1 time(s)
[0201/073229.084:WARNING:gpu_process_host.cc(982)] Reinitialized the GPU process after a crash. The reported initialization time was 28 ms
[0201/073229.095:ERROR:command_buffer_proxy_impl.cc(124)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.
[0201/073229.095:WARNING:ipc_message_attachment_set.cc(49)] MessageAttachmentSet destroyed with unconsumed attachments: 0/1
[0201/073229.096:WARNING:ipc_message_attachment_set.cc(49)] MessageAttachmentSet destroyed with unconsumed attachments: 0/1
please help me ,how to use proxy and avoid this problem? i use windows 7 x86 and CEFSharp WinForm 79 Thanks fro help