Coder Social home page Coder Social logo

Comments (4)

ScienJus avatar ScienJus commented on August 14, 2024

这里有可能跟轮训的次数有关,但是不太确定,我记得 java8 分支的轮训时间改为了 2 分钟,也会出现问题么?理论上和 w.qq.com 的时间是一样的啊

from smartqq.

TJYSunset avatar TJYSunset commented on August 14, 2024

@ScienJus 问题已经发现了,经测试是我给@Dilant提供的两个暴力函数的问题,在加入的群过多时会导致大量请求 (///)
所以说不是这个项目的问题

from smartqq.

Dilant avatar Dilant commented on August 14, 2024

@TJYSunset (我刚想说……)

@ScienJus
是的,问题出在我的“主类名.java” (sorry...)
我在里面使用了如下代码:

    private static String getNick(GroupMessage msg)
    {
        for (Group group : client.getGroupList())
        {
            if (msg.getGroupId() == group.getId())
            {
                for (GroupUser user : client.getGroupInfo(group.getCode()).getUsers())
                {
                    if (user.getUin() == msg.getUserId())
                    {
                        //......
                    }
                }
            }
        }
        return "昵称获取错误";
    }

每次收到消息,都会调用client.getGroupListclient.getGroupInfo,造成了大量请求,服务器自我保护而关闭连接。
我试着自己优化下调用逻辑吧。
感谢跟进,以及致歉。

from smartqq.

ScienJus avatar ScienJus commented on August 14, 2024

好的,Web QQ 服务器确实对调用次数比较敏感,我最开始的做法是在一开始就加载好所有的群成员和好友信息并缓存在内存里,然后收到消息时直接去拿就可以了,即便如此调用时也需要偶尔 Sleep 一下控制请求频率,就像是:

https://gist.github.com/ScienJus/f1ba1e5b1611cca662cc

from smartqq.

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.