记录于2021-02-22,OS为阿里云轻量应用服务器CentOS 7.3
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1614050923.823][SEVERE]: bind() failed: Cannot assign requested address (99)
ChromeDriver was started successfully.
先说结论:如果网络环境不需要用到ipv6,可以忽略此错误。该错误不会影响chromedriver 在ipv4下的运行。
配置IPv6地址可以解决此错误
服务器是阿里云的轻量应用服务器,OS是CentOS 7.3
阿里云官方文档:配置IPv6地址,包括自动配置工具下载和手动配置方法
下载完成后得到工具
ecs-util-ipv6
,运行它,成功则返回如下信息:
[root@izbp112i9bshiu2ybihp3mz admin]# chmod +x ecs-utils-ipv6
[root@izbp112i9bshiu2ybihp3mz admin]# ./ecs-utils-ipv6
[Info] ECS Utils IPv6 1.0.3.
[Info] IPv6 Auto Config Begin...
[Warn] get [00:16:3e:10:45:90] ipv6 metadata null
[Warn] get [00:16:3e:10:45:90] prefix len metadata null
[Warn] get [00:16:3e:10:45:90] ipv6 gateway metadata null
[Info] Config eth0...
[Done] IPv6 Auto Config Finished.
[root@izbp112i9bshiu2ybihp3mz admin]# ifconfig|grep -i inet6
inet6 fe80::216:3eff:fe10:4590 prefixlen 64 scopeid 0x20<link>
inet6 ::1 prefixlen 128 scopeid 0x10<host>
此时运行chromedriver,发现错误解决了:
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
网上一些文章提到增加运行参数可解决此问题
网上一些文章写到增加运行参数--verbose或者--whitelisted-ips解决此问题
--verbose:输出所有级别的日志
用此参数可以得到错误的全部信息listen on IPv6 failed with error ERR_ADDRESS_INVALID
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver -help | grep verbose
--verbose log verbosely (equivalent to --log-level=ALL)
--replayable (experimental) log verbosely and don't truncate long strings so that the log can be replayed.
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver --verbose
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1614051592.443][SEVERE]: bind() failed: Cannot assign requested address (99)
[1614051592.443][INFO]: listen on IPv6 failed with error ERR_ADDRESS_INVALID
ChromeDriver was started successfully.
--whitelisted-ips和--allowed-ips
在88版本的chromedriver的帮助信息中没有此参数,但是这个参数还可以使用:
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver --version
ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784})
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver -help | grep ips
--allowed-ips comma-separated allowlist of remote IP addresses which are allowed to connect to ChromeDriver
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver --whitelisted-ips
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
^C
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver --whitelisted-ips=66.66.66.72,66.66.66.71
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515
Remote connections are allowed by an allowlist (66.66.66.72,66.66.66.71).
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
与--whitelisted-ips
相近的有一个参数--allowed-ips
,测试后发现作用一样的
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver --allowed-ips
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
^C
[root@izbp112i9bshiu2ybihp3mz admin]# ./chromedriver --allowed-ips=66.66.66.72,66.66.66.71
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515
Remote connections are allowed by an allowlist (66.66.66.72,66.66.66.71).
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
增加这个参数后,确实不会出现bind() failed
,原理不清楚
这个参数的作用:是否允许远程ip连接
只允许本地连接
./chromedriver
:Only local connections are allowed.
允许所有远程连接
./chromedriver --allowed-ips
:All remote connections are allowed. Use an allowlist instead!
只允许列表中的ip连接
./chromedriver --allowed-ips=66.66.66.72,66.66.66.71
:Remote connections are allowed by an allowlist (66.66.66.72,66.66.66.71).
网友评论