作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 python 脚本,它使用请求库通过其网络界面连接到设备。它使用带有 https 连接的 url。
sess = requests.Session()
try:
resp = sess.post('https://' + device + '/url_admin/login.cgi', data=login_data, verify=False)
except Exception as e:
template = "Exception: {0}\nArguments: {1!r}"
print(template.format(type(e).__name__, e.args))
当我尝试从命令行执行它时,它工作得很好(即使是 apache 用户)。但是,当它被来自门户网站的 php 代码(exec 函数)触发时。它抛出这个错误
Exception: ConnectionError
Arguments: (MaxRetryError("HTTPSConnectionPool(host='some.device.com', port=443): Max retries exceeded with url: /url_admin/login.cgi (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f55aa8e6550>: Failed to establish a new connection: [Errno 13] Permission denied',))",),)
我不确定是什么原因,因为 apache 用户能够执行它并建立连接。为什么用php代码执行时连接不上?
最佳答案
setsebool -P httpd_can_network_connect on
关于php - 请求库 : Failed to establish a new connection: [Errno 13] Permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52528590/
我是一名优秀的程序员,十分优秀!