lgc-KoiDev / koishi-plugin-memes-api

Koishi 复刻版 表情包制作插件调用 API 版
MIT License
15 stars 4 forks source link

从meme-generator服务器Fetch keys失败 #22

Closed NaughtyChas closed 1 month ago

NaughtyChas commented 1 month ago

系统环境Ubuntu 22.04 64bit,koishi使用docker部署

2024-09-29 19:30:39 [I] loader apply plugin memes-api:j8mj25
2024-09-29 19:30:39 [E] memes-api MemeSource init failed!
2024-09-29 19:30:39 [E] memes-api MemeError: unexpected-error (Error: fetch http://127.0.0.2:2233/memes/keys failed)
                            at MemeSource.request (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:377:13)
                            at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
                            at async MemeSource.getKeys (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:395:24)
                            at async MemeSource.initMemeList (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:309:18)
                            at async MemeSource.init (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:296:5)
                            at async Object.apply (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:562:5)

meme-generator服务器按理讲应该已经成功部署:

root@[REDACTED]:~# curl http://127.0.0.2:2233/memes/keys
["pepe_raise","capoo_strike","printing","kiss","mourning","mihoyo","murmur","stew","marriage","chase_train","beat_head","acg_entrance","flush","maimai_join","hit_screen","what_I_want_to_do","paint","look_this_icon","this_chicken","shutup","beat_up","back_to_work","capoo_rub","maimai_awaken","hug","dinosaur","clauvio_twist","bubble_tea","genshin_start","dog_of_vtb","fight_with_sunuo","love_you","distracted","scratch_head","youtube","charpic","turn","dianzhongdian","jiujiu","painter","trance","bronya_holdsign","swirl_turn","wangjingze","weisuoyuwei","chanshenzi","qiegewala","shuifandui","zengxiaoxian","yalidaye","nihaosaoa","shishilani","wunian","maikease","oshi_no_ko","nahida_bite","jiji_king","tightly","prpr","divorce","father_work","thump","rise_dead","telescope","always_like","lick_candy","pyramid","funny_mirror","thermometer_gun","slogan","kaleidoscope","pass_the_buck","lim_x_0","throw_gif","read_book","hold_tight","need","5000choyen","hutao_bite","pound","think_what","what_he_wants","raise_sign","captain","nokia","klee_eat","washer","blamed_mahiro","symmetric","addiction","hold_grudge","roll","my_opinion","tankuku_raisesign","twist","safe_sense","you_should_call","ask","always","confuse","crawl","loading","tom_tease","let_me_in","add_chaos","punch","run_away","clown","fill_head","capoo_rip","atri_pillow","steam_message","pornhub","fade_away","follow","run","capoo_stew","eat","knock","pat","dont_touch","rotate_3d","fencing","keep_away","genshin_eat","suck","learn","loop","frieren_take","cover_face","erised_mirror","pinch","police","police1","throw","sit_still","petpet","ascension","potato","daynight","rip_angrily","smash","thump_wildly","imprison","google_captcha","capoo_draw","overtime","bluearchive","hammer","meteor","not_call_me","psyduck","guichu","note_for_leave","call_110","listen_music","subject3","gun","anti_kidnap","rip","why_at_me","no_response","karyl_point","interview","garbage","windmill_turn","make_friend","luxun_say","scroll","google","wooden_fish","rub","slap","certificate","kick_ball","out","anya_suki","wave","good_news","taunt","dog_dislike","little_angel","applaud","decent_kiss","scratchcard","nijika_holdsign","bite","play","raise_image","high_EQ","tomb_yeah","capoo_say","osu","left_right_jump","wujing","support","flash_blind","coupon","konata_watch","my_wife","wakeup","cyan","luoyonghao_say","shiroko_pero","my_friend","hug_leg","bad_news","wish_fail","dont_go_near","bocchi_draft","step_on","tease","look_flat","together","repeat","jump","perfect","nekoha_holdsign","blood_pressure","fanatic","vibrate","incivilization","kirby_hammer","mahiro_readbook","jerry_stare","teach","walnut_zoom","walnut_pad","find_chips","universal","top_notch","play_game","firefly_holdsign","china_flag","pixelate","ace_attorney_dialog","alike","name_generator","lost_dog","shock","play_together","why_have_hands","worship","douyin","wallpaper"]

请求设置中requestConfig.**endpoint**设置为http://127.0.0.2:2233

不知道是我的配置有问题,还是哪里出bug了。球球dev来帮帮忙 > <

lgc2333 commented 1 month ago

related to https://github.com/lgc-KoiDev/koishi-plugin-memes-api/issues/18 在重构了

NaughtyChas commented 1 month ago

看到您将#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运行


与报错有关的相关代码段:

Object.apply (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1417:5)

```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; } ```

ctx.$.updateInfos (/koishi/node_modules/koishi-plugin-memes-api/lib/index.js:1358:18)

```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)); }; ```


reqCatchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:130:11)
MemeError.catchWrapper (/koishi/node_modules/meme-generator-api/dist/index.cjs:119:14)

```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;

lgc2333 commented 1 month ago

请把此条日志上方的几个报错日志一起发出来

NaughtyChas commented 1 month ago

请把此条日志上方的几个报错日志一起发出来

下机上床了( 我明早提供一下完整日志吧

NaughtyChas commented 1 month ago

请把此条日志上方的几个报错日志一起发出来

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

lgc2333 commented 1 month ago

127.0.0.1 改成 host.docker.internal 试下

NaughtyChas commented 1 month ago

127.0.0.1 改成 host.docker.internal 试下

感谢!将容器内/etc/路径下的hosts和系统全局hosts下都添加了一条127.0.0.1 host.docker.internal,最终创建并启动容器时使用docker run --network host [...]解决问题了

XieXiLin2 commented 1 month ago

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 就好了。

lgc2333 commented 1 month ago

你是不是搞容器的时候没弄端口映射 推荐使用映射将容器端口映射到主机

对不起脑子抽了跟你说 docker.host.internal

NaughtyChas commented 1 month ago

你是不是搞容器的时候没弄端口映射 推荐使用映射将容器端口映射到主机

对不起脑子抽了跟你说 docker.host.internal

刚开始用Docker啥也不懂,大概是上次实例炸了之后重新部署忘做端口映射了(