Closed NaughtyChas closed 1 month ago
related to https://github.com/lgc-KoiDev/koishi-plugin-memes-api/issues/18 在重构了
看到您将#18标为Closed,Docker位置问题可能已经修复掉了。 重构的v1.0.0版本的插件似乎还是没能修复这个问题。虽然这个issue已经被Unplanned,但是我可以提供更多信息:
2024-10-03 00:08:24 [W] memes-api Error: fetch http://127.0.0.1:2233/memes/keys failed
at /koishi/node_modules/@koishijs/plugin-http/node_modules/@cordisjs/plugin-http/lib/index.cjs:319:23
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async [cordis.invoke] (/koishi/node_modules/@koishijs/plugin-http/node_modules/@cordisjs/plugin-http/lib/index.cjs:317:19)
at async MemeError.catchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:119:14)
at async reqCatchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:130:11)
at async ctx.$.updateInfos (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1358:18)
at async initMemeList (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1397:5)
at async Object.apply (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1417:5)
同样确定meme_generator已经成功在http://127.0.0.1:2233
运行
与报错有关的相关代码段:
```javascript const initMemeList = /* @__PURE__ */ __name(async () => { const tip = "获取表情信息中……"; ctx.$.notifier?.update({ type: "primary", content: tip }); await ctx.$.updateInfos( ctx.timer.throttle((now, total) => { const p = Math.ceil(now / total * 100); ctx.$.notifier?.update( /* @__PURE__ */ Element("p", { children: [ tip, /* @__PURE__ */ Element("progress", { percentage: p, duration: 1, children: [ now, " / ", total, " | ", p, "%" ] }) ] }) ); }, 250) ); }, "initMemeList"); try { await initMemeList(); // line 1417 } catch (e) { ctx.logger.warn("Failed to fetch meme list, plugin will not work"); ctx.logger.warn(e); ctx.$.notifier?.update({ type: "danger", content: /* @__PURE__ */ Element("p", { children: [ "获取表情信息失败,插件将不会工作!", /* @__PURE__ */ Element("br", {}), "请检查你的请求设置以及 meme-generator 的部署状态,更多信息请查看日志。" ] }) }); return; } ```
```javascript ctx.$.updateInfos = async (progressCallback) => { const keys = await ctx.$.api.getKeys(); // line 1358 const len = keys.length; progressCallback?.(0, len); let ok = 0; const limit = pLimit(config.getInfoConcurrency); const newEntries = await Promise.all( keys.map((key) => { return limit(async () => { const v = await ctx.$.api.getInfo(key); ok += 1; progressCallback?.(ok, len); return [key, v]; }); }) ); for (const k in ctx.$.infos) delete ctx.$.infos[k]; Object.assign(ctx.$.infos, Object.fromEntries(newEntries)); }; ```
```javascript async function catchWrapper(func) { try { return await func(); // line 119 } catch (e) { MemeError2.promiseCatchHandler(e); } } MemeError2.catchWrapper = catchWrapper; __name(catchWrapper, "catchWrapper"); })(MemeError || (MemeError = {})); // src/api.ts async function reqCatchWrapper(fn) { return (await MemeError.catchWrapper(fn)).data; // line 130 } ```
也许是和plugin-http
对接请求时出了问题?idk ;w;
请把此条日志上方的几个报错日志一起发出来
请把此条日志上方的几个报错日志一起发出来
下机上床了( 我明早提供一下完整日志吧
请把此条日志上方的几个报错日志一起发出来
2024-10-03 12:06:05 [I] loader apply plugin memes-api:04ovp1
2024-10-03 12:06:06 [W] memes-api Failed to fetch meme list, plugin will not work
2024-10-03 12:06:06 [W] memes-api Error: connect ECONNREFUSED 127.0.0.1:2233
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1607:16)
2024-10-03 12:06:06 [W] memes-api TypeError: fetch failed
at node:internal/deps/undici/undici:13178:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async [cordis.invoke] (/koishi/node_modules/@koishijs/plugin-http/node_modules/@cordisjs/plugin-http/lib/index.cjs:317:19)
at async MemeError.catchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:119:14)
at async reqCatchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:130:11)
at async ctx.$.updateInfos (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1358:18)
at async initMemeList (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1397:5)
at async Object.apply (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1417:5)
2024-10-03 12:06:06 [W] memes-api Error: fetch http://127.0.0.1:2233/memes/keys failed
at /koishi/node_modules/@koishijs/plugin-http/node_modules/@cordisjs/plugin-http/lib/index.cjs:319:23
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async [cordis.invoke] (/koishi/node_modules/@koishijs/plugin-http/node_modules/@cordisjs/plugin-http/lib/index.cjs:317:19)
at async MemeError.catchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:119:14)
at async reqCatchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:130:11)
at async ctx.$.updateInfos (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1358:18)
at async initMemeList (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1397:5)
at async Object.apply (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1417:5)
meme-generator的版本是0.1.4
。
127.0.0.1
改成 host.docker.internal
试下
127.0.0.1
改成host.docker.internal
试下
感谢!将容器内/etc/
路径下的hosts和系统全局hosts下都添加了一条127.0.0.1 host.docker.internal
,最终创建并启动容器时使用docker run --network host [...]
解决问题了
127.0.0.1
改成host.docker.internal
试下感谢!将容器内
/etc/
路径下的hosts和系统全局hosts下都添加了一条127.0.0.1 host.docker.internal
,最终创建并启动容器时使用docker run --network host [...]
解决问题了
不,其实不用这么麻烦的……
你要么在容器里用 host.docker.internal 直接访问主机资源,要么把容器的网络模式设置为 host 就好了。
你是不是搞容器的时候没弄端口映射 推荐使用映射将容器端口映射到主机
对不起脑子抽了跟你说 docker.host.internal
你是不是搞容器的时候没弄端口映射 推荐使用映射将容器端口映射到主机
对不起脑子抽了跟你说docker.host.internal
刚开始用Docker啥也不懂,大概是上次实例炸了之后重新部署忘做端口映射了(
系统环境Ubuntu 22.04 64bit,koishi使用docker部署
meme-generator服务器按理讲应该已经成功部署:
请求设置中
requestConfig.**endpoint**
设置为http://127.0.0.2:2233
。不知道是我的配置有问题,还是哪里出bug了。球球dev来帮帮忙 > <