danni-cool / wechatbot-webhook

轻量、可部署的微信机器人webhook服务,使用http接口收发微信消息, 用它作为个人通知、AIGC 应用或者 coze、n8n等自动化工作流的消息节点
MIT License
1.46k stars 258 forks source link

RECVD_MSG_API 连接失败 connect ECONNREFUSED ::1:3000 #244

Open brainkelly opened 1 month ago

brainkelly commented 1 month ago

提bug前先检查以下是否已经执行

bug描述

RECVD_MSG_API 设置为http://localhost:3000/receive/ , 扫码后提示链接失败 connect ECONNREFUSED ::1:3000,具体报错log见下文。 已经确认 http://localhost:3000/receive/ 已经处于监听状态,且post请求是有响应的

提供有用的信息

docker 启动命令:

sudo docker run -d --name wxBotWebhook --restart unless-stopped -p 3000:3000 -p 3001:3001 -v ~/wxBot_logs:/app/log -e ACCEPT_RECVD_MSG_MYSELF=true -e RECVD_MSG_API=http://localhost:3000/receive/ -e LOGIN_API_TOKEN=123 dannicool/docker-wechatbot-webhook

报错log:

[2024-09-28T14:48:39.506] [INFO] - starting fetching api: http://localhost:3000/receive/ [2024-09-28T14:48:39.515] [ERROR] - Error occurred when trying to send Data to RecvdApi FetchError: request to http://localhost:3000/receive/ failed, reason: connect ECONNREFUSED ::1:3000 at ClientRequest. (/app/node_modules/.pnpm/node-fetch-commonjs@3.3.2/node_modules/node-fetch-commonjs/index.js:2223:11) at ClientRequest.emit (node:events:529:35) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:517:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { type: 'system', errno: 'ECONNREFUSED', code: 'ECONNREFUSED', erroredSysCall: 'connect' }

danni-cool commented 3 weeks ago

试试本机局域网地址

在 Docker 中,如果你在容器内请求 localhost(或 127.0.0.1),那么请求会被发送到容器本身,而不是主机(即你的本地电脑)。每个容器都有自己的网络栈,所以容器内的 localhost 指向的是容器内部

hazzzzzy commented 1 week ago

启动项的接受消息处理地址设为http://host.docker.internal:3000/receive