【问题标题】:FetchError: request to https://discordapp.com/api/v7/gateway/bot failed, reason: read ECONNRESET [closed]FetchError:对 https://discordapp.com/api/v7/gateway/bot 的请求失败,原因:读取 ECONNRESET [关闭]
【发布时间】:2019-09-13 21:36:57
【问题描述】:

我正在使用 node.js 模块 discord.js 处理 Discord 机器人。

最近在使用工作 wifi 时(当机器人尝试登录时)出现错误,我认为该错误以某种方式配置导致其中断。

(node:104) UnhandledPromiseRejectionWarning: FetchError: request to https://discordapp.com/api/v7/gateway/bot failed, reason: read ECONNRESET
    at RequestHandler.execute (C:\Users\user\Desktop\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:106:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

错误是从使用 APIRequest 的文件 RequestHandler.js 引发的 来自文件APIRequest.js 的方法make 返回来自文件index.js 的函数fetch 的结果,该文件返回rejected promise

变量reqClientRequest(来自模块_http_clientreturned来自https模块的request方法。

如果我注释掉 req.on('error', function (err) { ... });,则会收到以下错误:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)
Emitted 'error' event at:
    at TLSSocket.socketErrorListener (_http_client.js:391:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

我认为这是从 here 抛出的,但它是 Node.js (internal/stream_base_commons.js) 的内部模块,我无法对其进行编辑并继续深入跟踪。必须编辑和重新编译,我不知道该怎么做。

当我转到https://discordapp.com/api/v7/gateway/bot 时,我得到了回复:

{"code": 0, "message": "401: Unauthorized"}

我需要帮助了解原始错误的确切原因以及是否有任何解决方法可以继续运行机器人。

【问题讨论】:

  • 它在办公室网络之外工作吗?
  • @silcakes 是的。这与代理或类似的东西有关。
  • 因此,在不了解您的网络设置的情况下,只能推测原因。您应该查询您公司的 FW 和网络政策以解决该问题。

标签: javascript node.js node-modules discord.js node-fetch


【解决方案1】:

我遇到了同样的问题,我刚刚检查了机器人登录令牌,它已经过时了。尝试在 Discord 开发者门户上生成新的机器人令牌!

【讨论】:

    猜你喜欢
    • 2021-01-18
    • 2021-06-19
    • 2021-09-29
    • 2019-08-09
    • 2023-01-26
    • 2020-09-14
    • 1970-01-01
    • 2020-01-28
    • 2016-09-08
    相关资源
    最近更新 更多