17 votes
Accepted

RESTful HTTP and websocket in the same application?

One of the core design goals of Websockets is that it allows both HTTP and Websocket protocols to be communicated over the same port. It achieves this by explicitly requiring a client to perform a ...
maple_shaft's user avatar
  • 26.5k
12 votes
Accepted

How to architecture a realtime-heavy websockets-based web application?

How to structure the data that is sent from the server to the user? Use the messaging pattern. Well, you're already using a messaging protocol, but I mean structure the changes as messages... ...
Kasey Speakman's user avatar
12 votes

Is Kafka needed in a realtime chat application?

If you have 1 server doing everything, there's really no reason to use Kafka at all. If you distribute, which you probably have to if you want to scale to millions of users, other aspects come in. ...
Robert Bräutigam's user avatar
10 votes

Is masking really necessary when sending from Websocket client

Masking is useless with wss:// aka WebSockets over SSL/TLS. Since it is recommended to use SSL/TLS whenever possible, you can reasonable conclude that masking covers a marginal use case.
Laurent Caillette's user avatar
7 votes
Accepted

What is the point of rooms in socket.io?

Rooms are a tool in socket.io servers for keeping track of groups of connected users. You can then iterate the sockets in a room or broadcast to all of them. There's really nothing more to them than ...
jfriend00's user avatar
  • 3,572
7 votes
Accepted

Is Kafka needed in a realtime chat application?

People think of kafka as a message broker, but it's also sort of a database that stores and retrieves messages in order, and tracks every consumer's place in that list. This is an extremely nice fit ...
Karl Bielefeldt's user avatar
6 votes

How to architecture a realtime-heavy websockets-based web application?

After a few months of work on the backend mainly, I have been able to use some of the advices here to address the problems the platform was facing. The main objective when rethinking the backend was ...
Philippe Durix's user avatar
6 votes
Accepted

How long should Websockets maintain connection

Creating a new connection is expensive in terms of resources. The goal of WebSocket is specifically to avoid creating connections on regular intervals, such as in the case of long polling. However, ...
Arseni Mourzenko's user avatar
6 votes
Accepted

Websockets vs Ajax for live search

You only need websockets if you want the communication to be initiated by the server, not the client. Unless I misunderstand, in your case, the client seems to initiate every communication. In that ...
Glorfindel's user avatar
  • 3,137
5 votes
Accepted

Proper usages of rooms/namespaces when making a News Feed with socket.io

Now that it has been nearly 3 years, and the software in question has been in production with hundreds of thousands of users this entire time, I am going to answer my own question. I went with option ...
Christian's user avatar
  • 189
5 votes
Accepted

Is there an equivalent to HTTP status codes for WebSockets messages?

Generally, you want your webservice to receive and respond json messages. This is to allow maximum flexibility for later. The addition of new fields doesn't change the underlying types expected on ...
Neil's user avatar
  • 22.7k
4 votes

Exact definition of Sec-Websocket-Key in Websocket Protocol

As per RFC6455 "The WebSocket Protocol", section 4.1 (page 18, point 7), the value of Sec-WebSocket-Key header MUST be a randomly selected 16 byte nonce (of any value meaning decimal values 0 to 255 ...
Emil's user avatar
  • 41
4 votes

Does a full duplex communication object conflict with single responsibility?

If you would like to split it up into several classes, the Java approach is exactly how you would approach it. class Socket method getInputStream returns InputStream method getOutputStream returns ...
rwong's user avatar
  • 16.8k
4 votes

Battery Impact: Idle vs Busy Websocket on iOS

According to this research paper: HTML5 Connectivity Methods and Mobile Power Consumption, you do consume a significant amount of energy maintaining an inactive websocket, because it is sending ...
Ross Gatih's user avatar
4 votes
Accepted

Should a push hold data or make the receiver trigger an API call?

The following questions may influence your choice: how long the server needs to compute its result ? is the result for a unique request or is it broadcasted to several requesters ? how large is the ...
Christophe's user avatar
  • 76.8k
4 votes

Socket on a webserver

Sockets are file descriptors with special abilities. While every socket somehow uses a port, they are not the same thing. A socket is identified by a local address+port and a remote address+port. ...
amon's user avatar
  • 134k
4 votes

How do big messaging apps keep users connected

There is no one answer to this, because over the years there have been many, many different chat programs and protocols, but there are a few basic ways of building it: Store and forward, with polling....
IMSoP's user avatar
  • 5,827
4 votes
Accepted

How can users be notified of changes during collaborative editing in a system like Google Docs?

To solve the question of how Google Docs works: Here is a Blog post by the guy who designed the syncing system of gdocs: https://neil.fraser.name/writing/sync/ The link point to a detailed writeup of ...
Max N's user avatar
  • 112
4 votes

How would a stateless server handle events when the user disconnects?

I am struggling to vision how can you possibly build a chat service in an stateless fashion. For this kind of bi-directional communication systems you need to keep track of the available clients which ...
George's user avatar
  • 168
4 votes
Accepted

Is websocket connection a driving adapter or driven adapter in hexagonal architecture

There is no problem. It is okay that the web socket service is both driving and driven. Let's see an example. You have a web shop where backend and frontend communicate via web socket. When the user ...
pschill's user avatar
  • 1,825
3 votes
Accepted

Best Data Structure for ordered list of connected users

What you choose might depend on the particular load you anticipate. But, I'd start with a simple Queue. Possibly extended with a naive O(n) complexity Remove(item). Or, use a Dictionary or Map to ...
svidgen's user avatar
  • 14.6k
3 votes

What is the point of rooms in socket.io?

Rooms are a logical grouping construct and have many benefits out of the box for developers using websockets: Rooms make it easier to broadcast to a given set of clients, without referring to ...
S.D.'s user avatar
  • 1,080
3 votes
Accepted

Does a full duplex communication object conflict with single responsibility?

In addition to the other very good answers here, one way to think about it is that you are not really improving the level of abstraction (in the direction of a full duplex capability) by applying ...
Erik Eidt's user avatar
  • 33.7k
3 votes
Accepted

How to explain to a trainee how a computer receives external messages

I always think of it as: The port is an address on the incoming packet The operating system has been told to put any messages coming into the computer with that port address to a particular place in ...
Louise's user avatar
  • 156
3 votes

Asynchronous socket.io for lots of concurrent messages

Could using a socket dramatically improve connection time so that the app is much more responsive at initial loading and in case of modifications in previews? Yes. Sockets are designed specifically ...
Robert Harvey's user avatar
3 votes

Keeping deploys in Sync

This depends on your architecture. When you deploy a web client and a web server, you cannot guarantee matching versions even if you deploy both at the same instant. Even if there is no caching at ...
Gort the Robot's user avatar
3 votes
Accepted

What pattern should I use to implement a Message Routing mechanism?

Your use of the service locator is fine. Your comrades probably heard "service Locator is an anti-pattern" without understanding the context. A service locator should not be used when dependency ...
JacquesB's user avatar
  • 58.7k
3 votes

Real Time Web Sockets Architecture

I'd say the 2nd solution is feasible, but, in any event, an event needs to be sent to the WS server which would broadcast a message to all clients connected. In an ideal world, I'd say a stream/...
Milan Velebit's user avatar
3 votes
Accepted

Application for forwarding data from websocket to HTTP method

You are using term websocket (instead of "serial port") and do not specify how do you plan to forward(expose) data via HTTP. Most likely you plan to make http call to "third" device from RPI but ...
Maxim Sagaydachny's user avatar
3 votes

Do I actually need a message broker or are websockets enough?

At a high-level, in your design, the PostgreSQL database is standing in for the Redis cache and/or messaging system. This can be made to work but you could run into scalability issues. When you use ...
JimmyJames's user avatar
  • 26.8k

Only top scored, non community-wiki answers of a minimum length are eligible