(502) 网关 PhantomJS 驱动程序初始化错误

(502) Bad Gateway PhantomJS driver initialize

我在 .NET Core 应用程序中使用 Selenium.WebDriver 3.8.0 并尝试像这样初始化 PhantomJS 驱动程序:

PhantomJSDriverService driverService = PhantomJSDriverService.CreateDefaultService("<path to PhantomJS binary file>", "phantomjs");
PhantomJSOptions options = new PhantomJSOptions();
driverService.Proxy = "{my proxy address}:{port}";
driverService.ProxyType = "http";

IWebDriver driver = new PhantomJSDriver(driverService, options);

当我在 CentOS 上 运行:

[INFO - 2018-01-15T13:28:48.526Z] GhostDriver - Main - running on port 46847 The remote server returned an error: (502) Bad Gateway. The remote server returned an error: (502) Bad Gateway. ... The remote server returned an error: (502) Bad Gateway.

如果我使用默认构造函数:IWebDriver driver = new PhantomJSDriver();,同样的错误发生。

在 CentOS 系统代理中 /etc/profile 是这样配置的:

MY_PROXY_URL="{my proxy address}:{port}"
HTTP_PROXY=$MY_PROXY_URL
HTTPS_PROXY=$MY_PROXY_URL
FTP_PROXY=$MY_PROXY_URL
http_proxy=$MY_PROXY_URL
https_proxy=$MY_PROXY_URL
ftp_proxy=$MY_PROXY_URL
export HTTP_PROXY HTTPS_PROXY FTP_PROXY http_proxy https_proxy ftp_proxy

可能是什么问题?我了解了 Google 中有关 Selenium、PhantomJS 和 CentOS 的所有查询

Cause of 502 Bad Gateway Errors Bad Gateway errors are often caused by issues between online servers that you have no control over. Source

服务器端可能存在一些问题,所以如您所见,除非服务器是您的,否则您可能无能为力。我与你的构造函数无关。

However, sometimes, there is no real issue but your browser thinks there is one thanks to an issue with your browser, a problem with your home networking equipment, or some other in-your-control reason. Source

另一方面,这可能是您的配置有问题。您可以做一些事情并尝试在此处修复它:Fix 502 Bad Gateway Error,如果您确实遇到问题,他们可能会帮助您。