4

Currently, im sending base64 strings over my socket.io 0.9 to send images around in my chat app.

I upgraded to socket.io 1.0, which in the documentation says it supports Binary data, like Buffers. I have little knowledge over what Buffers are, but can seem to get it work.

What is the advantage for me, would i move all my base64 string into Buffers and sending them, instead of the raw string. Does the Binary support do anything smart for large messages?

Laurens Kling
  • 2,221
  • 1
  • 21
  • 31
  • I use base64 too but I experience some problem when the file is big, user gets timeout: http://stackoverflow.com/questions/34734943/chat-message-is-blocked-when-sending-file-then-timeout-due-to-heartbeat Do it bother you? – Arch1tect Jan 13 '16 at 10:49

1 Answers1

2

socket.io introduced the ability to send binary data mainly because users asked for it.

If you send an image directly as a buffer, you will reduce the bandwidth. Base64 is approximately 37% larger than the original data size.

Source : base64 encoded image size

Community
  • 1
  • 1
p.o
  • 71
  • 2
  • Thanks! Is it also more stable? When i have a bad (mobile) connection and sending a big base64, the connection breaks sometimes. – Laurens Kling Jul 13 '14 at 19:01
  • Reliability is a problem in case of reconnection with mobile devices. You still need a confirmation system to know if the client got the image. – p.o Jul 13 '14 at 19:48