简体   繁体   English

如果从我的生产服务器向其他生产服务器发出 httprequest,则会出现连接错误,但它是通过 localhost 完成的

[英]Getting connection error if made httprequest from my production server to other production server , but its done with localhost

ConnectionError: HTTPSConnectionPool(host='remoteapiserver', port=443): Max retries exceeded with url: /api/post (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7feb54060bd0>: Failed to establish a new connection: [Errno 110]Connection timed out',))

code :代码 :

import requests
import json

url :"https://remoteapiserver.com/api/post"

headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

datas = {"foo":"bar"}

r = requests.post(url,data=json.dumps(datas),headers=headers)

hidden the url and domain隐藏网址和域名

both POST and GET are getting same error. POSTGET都收到相同的错误。

Please update your url value.请更新您的url值。 Something wrong with the python syntax and the formatting of your URL . python 语法和URL格式有问题。 It should be <protocol>://<server>/<context path>/<type>/<path> , please check this link for further more about URL formatting.它应该是<protocol>://<server>/<context path>/<type>/<path> ,请查看此链接以获取有关URL格式的更多信息。

url = 'https://www.remoteapiserver.com'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM