posts.getUpvoters - socket.io flood - user emit banned

NodeBB Plugins
  • Hello,
    I have a problem with 0.6.x that wasn't present in 0.5.x.
    I use in my theme deep-space a little script to show who have upvoted a post.
    For this I use a function which basically calls

    socket.emit('posts.getUpvoters', pid, function(err, data) {
    //doing stuff here
    });
    

    My problem is that I need to call it on every post and there seems to be a limit now

    19/1 15:39 [3652] - warn: Flooding detected! Calls : 21, Duration : 58
    19/1 15:39 [3652] - warn: [socket.io] Too many emits! Disconnecting uid : 1. Message : posts.getUpvoters
    [socket.io] Too many emits! Disconnecting uid : 1. Message : posts.getUpvoters
    

    And the big issue is that I'm not able to post anymore before restarting the server which is a real problem. For now I've deactivated this but I really like this feature and was hopping to release it as a plugin sometime and with this I'm kinda stuck.
    Is there any way to cheat on this ?

  • You can send an array of pids to the socket call now, so instead of making a call for every post just gather the pids you want and send them all.

    socket.emit('posts.getUpvoters', [1,2,3,4], function(err, data){
        console.log(data);
    });
    
  • @baris Thanks a bunch, is this also available for v0.6.x branch ?

  • Linked to this, but a bug since it's core.

    20/1 15:27 [18270] - warn: [socket.io] Too many emits! Disconnecting uid : 2. Message : topics.markAsRead
    
  • @esiao Are you able to reproduce this reliably? I spent some time trying to repro today but couldn't.

  • @baris It wasn't me I guess you need a large amount of unread post to reproduce this. (more than 20 if we follow the logic)

  • Hmm actually that message only shows the last emit, so the 19 before it could be any emit calls, I'll change the code so it keeps track of the previous 20 events to debug further.

  • Try updating to https://github.com/NodeBB/NodeBB/commit/aab2bc0b3923630c4d18ec8edc5ee7437e9e9917 and post the log when you get that too many emits warning.

  • @baris I have this one for now

    21/1 14:13 [30334] - warn: [socket.io] Too many emits! Disconnecting uid : 49. Events : meta.reconnected,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.notifyTyping,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.notifyTyping,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.notifyTyping,modules.composer.renderPreview,modules.composer.renderPreview,modules.composer.notifyTyping,modules.composer.renderPreview,user.search,modules.composer.renderPreview
    

    There's a least 3 users with the bug I'll update when I catch more.

  • Thanks looks like that user disconnected and then sent a bunch of render preview calls.

    meta.reconnected,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.notifyTyping,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.notifyTyping,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.notifyTyping,
    modules.composer.renderPreview,
    modules.composer.renderPreview,
    modules.composer.notifyTyping,
    modules.composer.renderPreview,
    user.search,
    modules.composer.renderPreview
    
  • @baris Here's the user of yesterday

    21/1 14:54 [30334] - warn: Flooding detected! Calls : 21, Duration : 959
    21/1 14:54 [30334] - warn: [socket.io] Too many emits! Disconnecting uid : 2. Events : topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead,topics.loadMore,topics.markAsRead
    
    
  • @baris

    socket.emit('posts.getUpvoters', [1,2,3,4], function(err, data){
        console.log(data);
    });
    

    Is not working when there's more than one post in the array. The data.usernames object is empty.
    And I'm sure that the posts have votes because I construct the array testing if the votes attribute is equal to 0 or not.

    Another question is there any avaible hook to fire my function when posts are loading inside a topic (infinite scroll). I've tested action:topic.loading and action:ajaxify.end but both gets only fired once.

    As for the logs of my uid 2 any idea on what's happening ?
    Thanks in advance.

  • Try with https://github.com/NodeBB/NodeBB/commit/835ad3ea537e80baad35e90b6b438b037f03cfa4

    Still haven't figured out why flooding is triggered for some users.

  • @baris Thanks the posts.getUpvoters is fixed 😉
    Any idea on how to fire the function when new posts are loaded while scrolling ? I think some http://api.jquery.com/ajaxcomplete/ could do the trick but it's kind of ugly no ?
    Also havin a hook that gives back the pids of the logged posts could be even more nice would avoid to do the ones already done.

  • The hook that's fired when new posts are loaded is action:posts.loaded I can add the pids to this hook which should help in this case.

  • You will get the loaded pids in the params of the hook with that commit.


Suggested Topics


  • 0 Votes
    3 Posts
    47 Views

    Oh!
    Thanks for the comment,
    In the meantime, I found a plugin that defines this, and on the server side I simply launch a socket, which is sent to the plugin, and then the plugin sends the notification.

  • 6 Votes
    14 Posts
    431 Views

    @baris just thinking about this, and perhaps it's a good idea to let users know when they've achieved a new level with either a notification message, or something else.

    Gamification is an important aspect of how forums work with reputation levels being a form of kudos for participants and some form of acknowledgement when a member reaches a specific level is nice to have rather than just silently taking place.

    It's mostly for acknowledgement of achievement.

  • 0 Votes
    6 Posts
    2k Views

    @baris and in the version like 1.2.1 how I can do ( I can't upgrade to 1.3.0) ? Because if I use 👍

    db.getSortedSetRevRange('uid:' + uid_of_user + ':bookmarks', 0, -1, callback);

    It's not work in the 1.2.1 maybe I can use:

    db.getSortedSetRange('uid:'+uid+":favourites",callback);?
  • 0 Votes
    2 Posts
    1k Views

    On the page ACP > Plugin > Composer (default) turn on the option "Use a separate route for the composer"

  • 6 Votes
    25 Posts
    12k Views

    Colors are disappearing if an enter made between lines?