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



  • 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 ?


  • Admin

    https://github.com/NodeBB/NodeBB/commit/2f955c3af4ffb3a4593e82c1343c4c17b864d5d4

    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
    

  • Admin

    @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)


  • Admin

    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.


  • Admin

    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.


  • Admin

    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.


  • Admin

    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.


  • Admin

    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.


  • Admin

    https://github.com/NodeBB/NodeBB/commit/288d507eb6096a594e71512b7bcaac90e22d6a3b

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


 


Star

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.