如何修复 Portainer Edge Agent [message: an error occured during short poll] [error: short poll request failed]
问题:
你正在尝试运行 Portainer Edge Agent,但无法连接到 Portainer UI 中的端点,但你在日志中看到类似这样的错误消息:
error_log.txt
2020/10/24 13:58:23 [ERROR] [internal,edge,poll] [message: an error occured during short poll] [error: short poll request failed]解决方案
首先,检查你的 EDGE_ID 和你的 EDGE_KEY。在大多数情况下,这些设置不正确,阻止了 Edge Agent 和 Portainer 实例之间的正确通信。
如果这没有帮助,检查你的防火墙。Portainer 实例的端口 8000。创建新端点时,Portainer 将显示类似这样的消息
portainer_agent_communication.txt
代理将通过 https://portainer.mydomain.com 和 tcp://portainer.mydomain.com:8000 与 Portainer 通信根据你的系统配置,你需要在防火墙上启用端口 8000,例如使用
test_nc.sh
sudo ufw enable 8000/tcp为了测试连接性,你可以使用 nc:
test_nc.sh
echo -e "\n" | nc portainer.techoverflow.net 8000这是在正常工作的 Portainer 实例上的样子:
test_nc.sh
$ echo -e "\n" | nc portainer.mydomain.com 8000
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close
400 Bad Request如果你没有看到任何响应,检查你的防火墙并检查你是否在 Portainer 容器上暴露了端口 8000。
此外,你可以在任何在线 base64 解码器(如 base64code.com)中解码你的 EDGE_KEY(使用 Portainer Edge Agent 实例中实际使用的那个):解码
edge_key_base64.txt
aHR0cHM6Ly9wb3J0YWluZXIubXlkb21haW4uY29tfHBvcnRhaW5lci5teWRvbWFpbi5jb206ODAwMHw3MTphNTpiYTpkMjo4MToxOToxMTo4NzplYTowZjo0NDo0YTpmYTo0Mjo4YTphNnwz将产生此字符串:
edge_key_decoded.txt
https://portainer.mydomain.com|portainer.mydomain.com:8000|71:a5:ba:d2:81:19:11:87:ea:0f:44:4a:fa:42:8a:a6|3你可以在其中检查 URL。例如,检查协议(http 或 https)是否与你用于配置主 Portainer 实例的不匹配。
最后,在运行 Portainer Edge Agent 的主机上,检查主机名是否正确解析:
check_hostname_resolution.sh
host portainer.mydomain.com这应该至少显示 Portainer 实例的 IPv4 地址。如果不正确,这些是最可能的原因:
- 你配置的 DNS 服务器无法正常工作。使用其他 DNS 服务器,如 1.1.1.1(
echo nameserver 1.1.1.1 > /etc/resolv.conf通常会临时修复此问题)。 - 你使用的域名的 DNS 记录未正确设置
- 如果你使用动态 DNS,你的 DDNS 客户端可能未正确更新记录
始终检查你从本地计算机获得的结果是否与从运行 Portainer Edge Agent 的主机获得的结果相同。
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow