2

I have a nodejs project that spawns multiple processes that communicate with socket io (the process both send data and receieve it). Sometimes during feature development, other programmers might do mistakes that will cause my socket infrastructure code to send large messages that are over size X (for example, over 500MB).

I am looking for a way to catch such cases and log them, I also wan't that such specific request specifically will fail.

Right now the behavior is that the entire socket connections fails (not just the specific big messages) and I didn't find anyway to even catch the case in order to know that this is the cause.

Right now I limit the message size with the "maxHttpBufferSize" configuration: Socket.IO doc about it here - "how many bytes or characters a message can be, before closing the session (to avoid DoS)." But I can't seem to catch any error when this size exceeds and the entire connection fails which is very bad for me.

I did think about trying to add some checks around my sending data through socket code, to check myself if the message size is to big, but serializing the data to make this check will have a very heavy price on performance, and socket.io code should already be doing this before sending the data so I don't want to make this happen twice.

The best solution i'm hoping to find is a socket.io supported way to handle this, if there is a different way that is performace costy that can also be good.

Note: I am working with socket io 2.0.4. If there is a fix only in higher version that's also acceptable.

Ziv Glazer
  • 786
  • 2
  • 8
  • 24
  • did you see https://stackoverflow.com/q/21706181/1358308 – Sam Mason Jan 10 '19 at 17:58
  • 1
    I did. "I did think about trying to add some checks around my sending data through socket code, to check myself if the message size is to big, but serializing the data to make this check will have a very heavy price on performance". The gist of the answer there is to serialize the data yourself which is bad like I stated. – Ziv Glazer Jan 12 '19 at 22:41
  • Any ideas? I'm really puzzled with this. – Ziv Glazer Jan 15 '19 at 11:24

0 Answers0