在这篇文章中,我们将为您详细介绍NoHttpResponseException:api.mch.weixin.qq.com:443failedtorespond的内容。此外,我们还会涉及一些关于aio
在这篇文章中,我们将为您详细介绍NoHttpResponseException:api.mch.weixin.qq.com:443 failed to respond的内容。此外,我们还会涉及一些关于aiohttp.client_exceptions.ClientConnectorError: 无法连接到主机 discord.com:443 ssl:default [连接调用失败 ('162.159.138.232', 443)]、aiohttp.client_exceptions.ClientConnectorError:无法连接到主机stackoverflow.com:443 ssl:default [连接呼叫失败('151.101.193.69',443)]、Android Studio模拟器出错,提示Application Installation Failed, Installation failed with message Failed to...、Apache HttpClient临时错误:NoHttpResponseException的知识,以帮助您更全面地了解这个主题。
本文目录一览:- NoHttpResponseException:api.mch.weixin.qq.com:443 failed to respond
- aiohttp.client_exceptions.ClientConnectorError: 无法连接到主机 discord.com:443 ssl:default [连接调用失败 ('162.159.138.232', 443)]
- aiohttp.client_exceptions.ClientConnectorError:无法连接到主机stackoverflow.com:443 ssl:default [连接呼叫失败('151.101.193.69',443)]
- Android Studio模拟器出错,提示Application Installation Failed, Installation failed with message Failed to...
- Apache HttpClient临时错误:NoHttpResponseException
NoHttpResponseException:api.mch.weixin.qq.com:443 failed to respond
证书不匹配,防火墙
aiohttp.client_exceptions.ClientConnectorError: 无法连接到主机 discord.com:443 ssl:default [连接调用失败 ('162.159.138.232', 443)]
如何解决aiohttp.client_exceptions.ClientConnectorError: 无法连接到主机 discord.com:443 ssl:default [连接调用失败 (''162.159.138.232'', 443)]
我正在尝试在 Debian Linux 系统上启动我的机器人。即使脚本在我的 Windows PC 上运行良好,它也给了我一个 ClientConnectorError。我能在这个问题上找到的只是来自 pythonanywhere 的东西,但我没有使用它。提前致谢:)
from discord.ext import commands
import os
from discord.ext.commands import *
intents = discord.Intents().all()
prefix = ''*''
client = commands.Bot(command_prefix=prefix,intents=intents)
@client.event
async def on_command_error(ctx,error):
if isinstance(error,CommandNotFound):
await ctx.send("UnkNown command. Use \\"" + prefix + "help\\" for a list of commands.")
return
if isinstance(error,MissingrequiredArgument):
await ctx.send("You are missing a required argument. Use \\"" + prefix + "help " + str(ctx.message.content).replace(prefix,"").split(" ")[0] + "\\" for help.")
return
try:
type(error.original)
if isinstance(error.original,ExtensionNotFound):
await ctx.send("The Extension \\"" + str(ctx.message.content).split(" ")[1] + "\\" does not exist.")
return
if isinstance(error.original,ExtensionNotLoaded):
await ctx.send("The specified extension \\"" + str(ctx.message.content).split(" ")[1] + "\\" is not loaded.")
return
if isinstance(error.original,ExtensionAlreadyLoaded):
await ctx.send("The specified extension \\"" + str(ctx.message.content).split(" ")[1] + "\\" is already loaded.")
return
except:
pass
raise error
@client.command()
async def load(ctx,extension):
if str(ctx.author.id) == ''special'':
client.load_extension(f''cogs.{extension}'')
await ctx.send("The extension \\"" + str(ctx.message.content).split(" ")[1] + "\\" was successfully loaded.")
@client.command()
async def unload(ctx,extension):
if str(ctx.author.id) == ''special'':
client.unload_extension(f''cogs.{extension}'')
await ctx.send("The extension \\"" + str(ctx.message.content).split(" ")[1] + "\\" was successfully unloaded.")
@client.command()
async def reload(ctx,extension):
if str(ctx.author.id) == ''special'':
client.unload_extension(f''cogs.{extension}'')
client.load_extension(f''cogs.{extension}'')
await ctx.send("The extension \\"" + str(ctx.message.content).split(" ")[1] + "\\" was successfully reloaded.")
for filename in os.listdir(os.path.join(os.path.dirname(__file__),''cogs'')):
if filename.endswith(''.py''):
client.load_extension(f''cogs.{filename[:-3]}'')
client.run(''token :)'')```
aiohttp.client_exceptions.ClientConnectorError:无法连接到主机stackoverflow.com:443 ssl:default [连接呼叫失败('151.101.193.69',443)]
如何解决aiohttp.client_exceptions.ClientConnectorError:无法连接到主机stackoverflow.com:443 ssl:default [连接呼叫失败(''151.101.193.69'',443)]?
这是我的代码:
import asyncio
import aiohttp
async def main():
loop = asyncio.get_event_loop()
url = "https://stackoverflow.com/"
async with aiohttp.ClientSession(loop=loop) as session:
async with session.get(url,timeout=30) as resp:
print(resp.status)
asyncio.run(main())
如果我在计算机上运行它,一切正常,但是如果我在pythonanywhere上运行,则会出现此错误:
Traceback (most recent call last):
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 936,in _wrap_create_connection
return await self._loop.create_connection(*args,**kwargs) # type: ignore # noqa
File "/usr/lib/python3.8/asyncio/base_events.py",line 1017,in create_connection
raise exceptions[0]
File "/usr/lib/python3.8/asyncio/base_events.py",line 1002,in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.8/asyncio/base_events.py",line 916,in _connect_sock
await self.sock_connect(sock,address)
File "/usr/lib/python3.8/asyncio/selector_events.py",line 485,in sock_connect
return await fut
File "/usr/lib/python3.8/asyncio/selector_events.py",line 517,in _sock_connect_cb
raise OSError(err,f''Connect call Failed {address}'')
ConnectionRefusedError: [Errno 111] Connect call Failed (''151.101.193.69'',443)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "test_c.py",line 39,in <module>
asyncio.run(main())
File "/usr/lib/python3.8/asyncio/runners.py",line 43,in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py",line 608,in run_until_complete
return future.result()
File "test_c.py",line 28,in main
async with session.get(url,timeout=30) as resp: #,headers=headers
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/client.py",line 1012,in __aenter__
self._resp = await self._coro
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/client.py",line 480,in _request
conn = await self._connector.connect(
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 523,in connect
proto = await self._create_connection(req,traces,timeout)
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 858,in _create_connection
_,proto = await self._create_direct_connection(
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 1004,in _create_direct_connection
raise last_exc
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 980,in _create_direct_connection
transp,proto = await self._wrap_create_connection(
File "/home/0dminnimda/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 943,in _wrap_create_connection
raise client_error(req.connection_key,exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host stackoverflow.com:443 ssl:default [Connect call Failed (''151.101.193.69'',443)]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f25a71d1a90>
1-托管上的aiohttp,2-我的计算机上的aiohttp
Name: aiohttp
Version: 3.6.2
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: /home/0dminnimda/.local/lib/python3.8/site-packages
Requires: chardet,async-timeout,multidict,yarl,attrs
required-by:
Name: aiohttp
Version: 3.6.2
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: c:\users\asus\appdata\roaming\python\python38\site-packages
Requires: async-timeout,attrs,chardet,multidict
required-by:
我很茫然,不是吗?我正在使用python3.8运行两个文件。
我也尝试了其他网址,它们有相同的问题
我需要添加更多详细信息吗?
解决方法
参考help from the forum,我在创建客户端时添加了trust_env = True
,现在一切正常。这是新代码:
import asyncio
import aiohttp
async def main():
loop = asyncio.get_event_loop()
url = "https://stackoverflow.com/"
async with aiohttp.ClientSession(loop=loop,trust_env=True) as session:
async with session.get(url,timeout=30) as resp:
print(resp.status)
asyncio.run(main())
,
如果您使用带有 python(3.8 或更高版本)和 aiohttp(3.7.4 或更高版本)的 Windows 操作系统
有时,像 ... Cannot connect to host <REQUESTED URL>:443 ssl:default [The parameter is incorrect]
这样的异常的解决方案是:
import sys
...
policy = asyncio.WindowsSelectorEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
asyncio.run(main())
你可以检查你的 Python 版本和操作系统:
import sys
...
if (sys.platform.startswith(''win'')
and sys.version_info[0] == 3
and sys.version_info[1] >= 8):
policy = asyncio.WindowsSelectorEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
asyncio.run(main())
here,in issue 4536,一切都有更详细的描述。
Android Studio模拟器出错,提示Application Installation Failed, Installation failed with message Failed to...
多次运行模拟机总会出现下面的错误,试了很多方法也是不行,什么操作菜单Build->Close project之类的。
错误翻译,了解了是什么错误再找怎么解决吧,我用的是Android Studio的模拟机,所以直接按下面操作就行了,如果用的是手机之类的再搜索其它办法吧。
Application Installation Failed
Installation failed with message Failed to establish session.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
=========
应用程序安装失败
安装失败,消息未能建立会话。
如果存在apk的现有版本,则可以通过卸载该版本来解决此问题,然后重新安装。
警告:卸载将删除应用程序数据!
要卸载现有应用程序吗?
解决方法:在菜单“Tools->AVD Manager,在打开AVD界面用的模拟器后面点击”向下三角“,然后点击”Wipe Data"清除数据,然后就可以用了。
Apache HttpClient临时错误:NoHttpResponseException
我有一个Web服务正在接受XML的POST方法。它工作正常,然后在某个随机的时刻,它无法与服务器通信,并抛出message,并抛出IOExceptionThe target server failed to respond
。后续调用工作正常。
当我打了一些电话然后将应用程序闲置大约10-15分钟时,它就会发生。在此之后我进行的第一个调用将返回此错误。
我尝试了几件事…
我像这样设置重试处理程序
HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() { public boolean retryRequest(IOException e, int retryCount, HttpContext httpCtx) { if (retryCount >= 3){ Logger.warn(CALLER, "Maximum tries reached, exception would be thrown to outer block"); return false; } if (e instanceof org.apache.http.NoHttpResponseException){ Logger.warn(CALLER, "No response from server on "+retryCount+" call"); return true; } return false; } }; httpPost.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
但是此重试从未被调用过。(是的,我正在使用正确的instanceof子句)。在调试时,此类永远不会被调用。
我什至尝试设置HttpProtocolParams.setUseExpectContinue(httpClient.getParams(),false);
但没有用。有人可以建议我现在可以做什么吗?
重要事项 除了弄清楚为什么我会得到例外,我还有一个重要的担忧是为什么重试处理程序不在这里工作?
答案1
小编典典由连接管理器保持活动状态的最有可能的持久连接变得陈旧。也就是说,目标服务器会在其连接空闲时关闭其末端的连接,而HttpClient无法对该事件做出反应,从而使连接半关闭或“陈旧”。通常这不是问题。HttpClient使用多种技术来验证从池中租借时的连接有效性。即使禁用了过时的连接检查并且使用了过时的连接来传输请求消息,请求执行通常也会在具有SocketException的写操作中失败,并会自动重试。但是,在某些情况下,写操作可以毫无例外地终止,随后的读操作将返回-1(流的结尾)。
解决此问题的最简单方法是将过期的连接和闲置了超过一段时间(例如,在池中闲置一分钟之后)之后空闲的连接驱逐出去。有关详细信息,请参见HttpClient教程的本节。
我们今天的关于NoHttpResponseException:api.mch.weixin.qq.com:443 failed to respond的分享就到这里,谢谢您的阅读,如果想了解更多关于aiohttp.client_exceptions.ClientConnectorError: 无法连接到主机 discord.com:443 ssl:default [连接调用失败 ('162.159.138.232', 443)]、aiohttp.client_exceptions.ClientConnectorError:无法连接到主机stackoverflow.com:443 ssl:default [连接呼叫失败('151.101.193.69',443)]、Android Studio模拟器出错,提示Application Installation Failed, Installation failed with message Failed to...、Apache HttpClient临时错误:NoHttpResponseException的相关信息,可以在本站进行搜索。
本文标签: