68

Regarding node.js, I'm using socket.io for real-time socket connection from the client application to the server application. I just heard about engine.io. Is engine.io a replacement for socket.io? I could not find any useful information on engine.io's website.

0

4 Answers 4

120

engine.io is a lower level library than socket.io.

Engine is to Socket.IO what Connect is to Express.

If you want the lower level abstraction, use engine.io. If you want a websocket abstraction, keep using socket.io.

engine.io is of more interest to you if you're building a library/framework on top of socket.io.

socket.io is of more interest to you if you're building an application on top of socket.io.

1
  • Clear Answer, Thanks! So if i need multiplexing i should use Socket.IO
    – Julian
    Jun 28, 2016 at 20:49
25

socket.io is built on top of engine.io.

socket.io is engine.io with bells and whistles.

if you don't need everything socket.io has (redis store, groups, etc.) just use engine.

1
22

A bit late to the game :-), but I'll mention it here for posterity.

Aside from being "lower level", one of the most important differences is socket.io will start with websockets first & degrade until it finds a transport that can work. On the other hand, engine.io will start with short polling (and upgrade on the side until it hits a wall).

Why?

From the user perspective, an unsuccessful WebSocket connection can translate in up to at least 10 seconds of waiting for the realtime application to begin exchanging data. This perceptively hurts user experience.

At the moment (2013), websockets isn't pervasive yet (e.g. older browsers, cellular networks, etc.) so it's smart to start with the XHR 1st.

See https://github.com/socketio/engine.io (Goals section) for more info.

8

Socket.IO v0.9 is outdated and a bit buggy, and Engine.IO is the interim successor. Socket.IO v1.0 (which will be released soon) will use Engine.IO and be much better than v0.9.

In my tests, Engine.IO appeared to perform better than Socket.IO v0.9, see the comparison: https://medium.com/node-js-javascript/b63bfca0539

Socket.IO tries to reconnect for some time after connection is lost, whereas Engine.IO does not.

Socket.IO supports rooms whereas Engine.IO does not. You would need rooms (either via these modules or your own implementation) if you'll have connections listening to different data/channel.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.