Does Spring @SubscribeMapping really subscribe the client to some topic?

By default the return value from an @SubscribeMapping method is sent as a message directly back to the connected client and does not pass through the broker. (emphasis mine) Here the Spring Framework documentation is describing what happens with the response message, not the incoming SUBSCRIBE message. So to answer your questions: yes, the client … Read more

How WebSocket server handles multiple incoming connection requests?

Your question is great! I would like to try to answer it from the point of view involving the system calls listen() and accept(). Understanding the behavior of these two calls I think is quite insightful and sufficient to answer your question. Spoiler: we can answer your question by looking into how TCP/IP works 🙂 … Read more

What are the pitfalls of using Websockets in place of RESTful HTTP?

With RESTful HTTP you have a stateless request/response system where the client sends request and server returns the response. With webSockets you have a stateful (or potentially stateful) message passing system where messages can be sent either way and sending a message has a lower overhead than with a RESTful HTTP request/response. The two are … Read more

Sending message to specific user on Spring Websocket

Oh, client side no need to known about current user, server will do that for you. On server side, using following way to send message to a user: simpMessagingTemplate.convertAndSendToUser(username, “/queue/reply”, message); Note: Using queue, not topic, Spring always using queue with sendToUser On client side stompClient.subscribe(“/user/queue/reply”, handler); Explain When any websocket connection is open, Spring … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)