Spring WebSocket Connecting with SockJS to a different domain

Jax’s answer was correct 🙂 The registerStompEndpoints method gives us the opportunity to set the Allowed Origins. We need to add it before the “withSockJs()” option. @Override public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) { stompEndpointRegistry.addEndpoint(“/BO/socket”).setAllowedOrigins(“*”).withSockJS(); }

What do these numbers mean in socket.io payload?

I know you asked a while ago, but the information remains for those who are researching. I did an analysis with reverse engineering in version 2.3.0 (socket.io) and 3.4.2 (engine.io) and got the following: The first number is the type of communication for engine.io, using the enumerator: Key Value 0 “open” 1 “close” 2 “ping” … Read more

socket.io determine if a user is online or offline

If your clients have specific user IDs they need to send them to socket.io server. E.g. on client side you can do // Browser (front-end) <script> const socket = io(); socket.emit(‘login’,{userId:’YourUserID’}); </script> And on server you will put something like // server (back-end) const users = {}; io.on(‘connection’, function(socket){ console.log(‘a user connected’); socket.on(‘login’, function(data){ console.log(‘a … Read more

At what point are WebSockets less efficient than Polling?

The whole point of a websocket connection is that you don’t ever have to ping the app for changes. Instead, the client just connects once and then the server can just directly send the client changes whenever they are available. The client never has to ask. The server just sends data when it’s available. For … Read more

How to run multiple coroutines concurrently using asyncio?

You can use gather. From the Python documentation: import asyncio async def factorial(name, number): f = 1 for i in range(2, number + 1): print(f”Task {name}: Compute factorial({i})…”) await asyncio.sleep(1) f *= i print(f”Task {name}: factorial({number}) = {f}”) async def main(): # Schedule three calls *concurrently*: await asyncio.gather( factorial(“A”, 2), factorial(“B”, 3), factorial(“C”, 4), ) … Read more

Engine.io or SockJS, which one to choose?

Have you looked at Primus? It offers the cookie requirements you mention, it supports all of the major ‘real-time’/websocket libraries available and is a pretty active project. To me it also sounds like vendor lock-in could be a concern for you and Primus would address that. The fact that it uses a plugin system should … Read more