Giter Club home page Giter Club logo

Comments (11)

cyanray avatar cyanray commented on June 12, 2024

检查一下mah的配置文件,有没有开启ws(websocket)

内容大概是:

adapter:
- http
- ws

理论上没开启ws应该要抛出异常,但是不知道为何没有抛出异常。(难以抽出时间维护该项目,该问题可能长期存在)

from mirai-cpp.

Yastruhank avatar Yastruhank commented on June 12, 2024

检查一下mah的配置文件,有没有开启ws(websocket)

内容大概是:

adapter:
- http
- ws

理论上没开启ws应该要抛出异常,但是不知道为何没有抛出异常。(难以抽出时间维护该项目,该问题可能长期存在)

mah的配置文件中是开启了ws的,并且在mirai主程序的控制台输出中也显示 Mirai HTTP API: adaptors: [http,ws]

from mirai-cpp.

cyanray avatar cyanray commented on June 12, 2024

是所有事件都无法触发回调函数吗,具体是哪个事件呢?
有试过 FriendMessage, GroupMessage, Message 这类事件吗,有些不常用事件缺乏测试,可能哪里写错了没发现导致无法触发。

也试试捕捉事件解析错误:

bot.On<EventParsingError>([&](EventParsingError e)
{
    try
    {
        e.Rethrow();
    }
    catch (const std::exception& ex)
    {
        cout << "解析事件时出现错误: " << ex.what() << endl;
    }
});

更有可能是网络问题,检查 hostname,port 有没有设置错误。

from mirai-cpp.

Yastruhank avatar Yastruhank commented on June 12, 2024

是所有事件都无法触发回调函数吗,具体是哪个事件呢? 有试过 FriendMessage, GroupMessage, Message 这类事件吗,有些不常用事件缺乏测试,可能哪里写错了没发现导致无法触发。

也试试捕捉事件解析错误:

bot.On<EventParsingError>([&](EventParsingError e)
{
    try
    {
        e.Rethrow();
    }
    catch (const std::exception& ex)
    {
        cout << "解析事件时出现错误: " << ex.what() << endl;
    }
});

更有可能是网络问题,检查 hostname,port 有没有设置错误。

是所有事件都无法触发,包括例程也是。这个函数我也试了,也没有被触发。hostname和port应该没有配置出错。请问程序有日志系统之类的东西用来分析吗?

from mirai-cpp.

cyanray avatar cyanray commented on June 12, 2024

是所有事件都无法触发回调函数吗,具体是哪个事件呢? 有试过 FriendMessage, GroupMessage, Message 这类事件吗,有些不常用事件缺乏测试,可能哪里写错了没发现导致无法触发。
也试试捕捉事件解析错误:

bot.On<EventParsingError>([&](EventParsingError e)
{
    try
    {
        e.Rethrow();
    }
    catch (const std::exception& ex)
    {
        cout << "解析事件时出现错误: " << ex.what() << endl;
    }
});

更有可能是网络问题,检查 hostname,port 有没有设置错误。

是所有事件都无法触发,包括例程也是。这个函数我也试了,也没有被触发。hostname和port应该没有配置出错。请问程序有日志系统之类的东西用来分析吗?

那就只能是网络问题了。

你可以试着在 mirai_bot.cpp 的这一行 打断点,看看新事件到达时会不会触发断点,如果不会,说明 Websocket 没成功建立连接。

然后在 websocketClient.cpp 的这一行打断点,检查局部变量 response_buffer 的内容。(我猜测可能还没执行到这里就抛出异常了)

from mirai-cpp.

Yastruhank avatar Yastruhank commented on June 12, 2024

是所有事件都无法触发回调函数吗,具体是哪个事件呢? 有试过 FriendMessage, GroupMessage, Message 这类事件吗,有些不常用事件缺乏测试,可能哪里写错了没发现导致无法触发。
也试试捕捉事件解析错误:

bot.On<EventParsingError>([&](EventParsingError e)
{
    try
    {
        e.Rethrow();
    }
    catch (const std::exception& ex)
    {
        cout << "解析事件时出现错误: " << ex.what() << endl;
    }
});

更有可能是网络问题,检查 hostname,port 有没有设置错误。

是所有事件都无法触发,包括例程也是。这个函数我也试了,也没有被触发。hostname和port应该没有配置出错。请问程序有日志系统之类的东西用来分析吗?

那就只能是网络问题了。

你可以试着在 mirai_bot.cpp 的这一行 打断点,看看新事件到达时会不会触发断点,如果不会,说明 Websocket 没成功建立连接。

然后在 websocketClient.cpp 的这一行打断点,检查局部变量 response_buffer 的内容。(我猜测可能还没执行到这里就抛出异常了)

有进入第一个断点,在第二个断电response_buffe的内容是101 switching protocois

QQ截图20211017172303

from mirai-cpp.

cyanray avatar cyanray commented on June 12, 2024

是所有事件都无法触发回调函数吗,具体是哪个事件呢? 有试过 FriendMessage, GroupMessage, Message 这类事件吗,有些不常用事件缺乏测试,可能哪里写错了没发现导致无法触发。
也试试捕捉事件解析错误:

bot.On<EventParsingError>([&](EventParsingError e)
{
    try
    {
        e.Rethrow();
    }
    catch (const std::exception& ex)
    {
        cout << "解析事件时出现错误: " << ex.what() << endl;
    }
});

更有可能是网络问题,检查 hostname,port 有没有设置错误。

是所有事件都无法触发,包括例程也是。这个函数我也试了,也没有被触发。hostname和port应该没有配置出错。请问程序有日志系统之类的东西用来分析吗?

那就只能是网络问题了。
你可以试着在 mirai_bot.cpp 的这一行 打断点,看看新事件到达时会不会触发断点,如果不会,说明 Websocket 没成功建立连接。
然后在 websocketClient.cpp 的这一行打断点,检查局部变量 response_buffer 的内容。(我猜测可能还没执行到这里就抛出异常了)

有进入第一个断点,在第二个断电response_buffe的内容是101 switching protocois

QQ截图20211017172303

看起来没有问题啊,图中显示你收到了刚建立连接时MAH发的一个包,试着给你的机器人发条消息触发消息事件,看看还能进入第一个断点吗。

会不会是因为网络原因断开连接了,记得处理 LostConnection 事件

from mirai-cpp.

Yastruhank avatar Yastruhank commented on June 12, 2024

是所有事件都无法触发回调函数吗,具体是哪个事件呢? 有试过 FriendMessage, GroupMessage, Message 这类事件吗,有些不常用事件缺乏测试,可能哪里写错了没发现导致无法触发。
也试试捕捉事件解析错误:

bot.On<EventParsingError>([&](EventParsingError e)
{
    try
    {
        e.Rethrow();
    }
    catch (const std::exception& ex)
    {
        cout << "解析事件时出现错误: " << ex.what() << endl;
    }
});

更有可能是网络问题,检查 hostname,port 有没有设置错误。

是所有事件都无法触发,包括例程也是。这个函数我也试了,也没有被触发。hostname和port应该没有配置出错。请问程序有日志系统之类的东西用来分析吗?

那就只能是网络问题了。
你可以试着在 mirai_bot.cpp 的这一行 打断点,看看新事件到达时会不会触发断点,如果不会,说明 Websocket 没成功建立连接。
然后在 websocketClient.cpp 的这一行打断点,检查局部变量 response_buffer 的内容。(我猜测可能还没执行到这里就抛出异常了)

有进入第一个断点,在第二个断电response_buffe的内容是101 switching protocois
QQ截图20211017172303

看起来没有问题啊,图中显示你收到了刚建立连接时MAH发的一个包,试着给你的机器人发条消息触发消息事件,看看还能进入第一个断点吗。

会不会是因为网络原因断开连接了,记得处理 LostConnection 事件

发送消息后有进入第一个断点

QQ截图20211017172303

但是没有进入回调函数

QQ截图20211017175100

from mirai-cpp.

cyanray avatar cyanray commented on June 12, 2024

这问题有点奇怪,我也看不懂了……

截图里你收到了 FriendInputStatusChangedEvent 事件,第一个断点你是否进入了两次?(第二次才是真正的好友消息事件)
试试 bot.On 看看能不能触发 FriendInputStatusChangedEvent 事件的回调函数。

from mirai-cpp.

cyanray avatar cyanray commented on June 12, 2024

也可以加Q群 1013323391,可能交流方便点。// TODO: 将真实原因和解决方案回复在该帖子。

from mirai-cpp.

cyanray avatar cyanray commented on June 12, 2024

错误原因:注释了 magic_enum 的断言,虽然通过编译,但是 magic_enum 不能正常工作。
解决方法:升级 MinGW

magic_enum 对编译器的要求:

  • Clang/LLVM >= 5
  • MSVC++ >= 14.11 / Visual Studio >= 2017
  • Xcode >= 10
  • GCC >= 9
  • MinGW >= 9

from mirai-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.