vs web sockets? Which is better? vs web sockets? Which is better?


4 min read

The applications for sockets are endless. It solved a lot of problems that developers have had for ages. Web sockets allowed us to persist connections to servers and exchange messages without needing to rely on bulky HTTP requests on every request. This basically applies to both web sockets and So what's the difference? Is there any? And which is better for you?


Let's start by talking about the similarities. In short, is a wrapper around web sockets. In fact, you literally choose between long polling and web sockets as a transport when creating a server.

But you need to be considerate since states in its documentation that you should not try to connect to a server with a web sockets library because adds a lot of intermediate layers which makes them sort of incompatible (another way of saying really hard/time consuming to re-implement)


How about differences? Well, when using you can send named messages. Although in web sockets you can imitate that behavior by always sending an object with a type and data attributes where the type is the message name and the fata being the data that needs to be sent. It's just easier to simply name the message in and you don't need to have a large switch statement in your on message event in web sockets. Another core difference is that supports long polling. This means that the connection will try to send the data in the form of a normal HTTP request instead of opening a web socket connection. Why is this important you may ask? Well, it's because some old browsers may not be compatible with web sockets.

What does is that it asks you to order the transports long polling and web sockets) in the order you prefer. By default it has long polling first followed by web sockets. This means (using default configuration) that will connect using long polling and then try to upgrade to web sockets which is basically the better option but it starts with the option that is for sure will work on all devices (long polling). This way if you use, you are sure that the implementation will work regardless of the client's ability to handle web sockets or not. On the other hand, if you're using web sockets, you will have to check if the client is compatible with it or not. You can try and configure for a different behavior as you see fit of course like for example force it to use only web sockets or only long polling for example.

Some great features

One other thing that does better than web sockets is that it provides the user to implement a callback which allows the server to reply to a certain message like it's a HTTP request, but at the same time it isn't HTTP.

Another really awesome feature is the ability to attach things to a connection like a cookie or an auth header which allows users to implement many features like auth for example with ease instead of relying on complex architectural decisions.

The downside of

A problem that might be the deciding factor for you when choosing is the libraries available. itself lists libraries for around 7 major programming languages but you might be using something different. At this point, you might need to rely on community maintained implementations of and you might be forced into using an older version of because the library hasn't been updated. On the other hand, web sockets is basically built into programming languages since it's a standard protocol.

In a nutshell

We, at, believe that is the simpler, more versatile solution. It provides great features with a lot less complexity than web sockets does. And since entracked aims to create the simplest experience, we decided to go with in our own system.

What do you think? Do you agree with our decision? Which one do you use for your projects? Let us know in the comments below.

By Omar Waleed, Founder of Entracked