Where “user” comes from in convertAndSendToUser works in SockJS+Spring Websocket?

We know we can send messages to the client from a stomp server using the topic prefixes that he is subscribed to e.g. /topic/hello. We also know we can send messages to a specific user because spring provides the convertAndSendToUser(username, destination, message) API. It accepts a String username which means if we somehow have a … Read more

Header in the response must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’

Problem: You are not configuring ‘Access-Control-Allow-Origin’ correctly and your current configuration is simply ignored by the server. Situation: The Error stack trace says: The value of the ‘Access-Control-Allow-Origin’ header in the response must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’. Origin ‘http://localhost:4200‘ is therefore not allowed access. It means that … Read more

How to unmarshal an escaped JSON string

You might want to use strconv.Unquote on your JSON string first 🙂 Here’s an example, kindly provided by @gregghz: package main import ( “encoding/json” “fmt” “strconv” ) type Msg struct { Channel string Name string Msg string } func main() { var msg Msg var val []byte = []byte(`”{\”channel\”:\”buu\”,\”name\”:\”john\”, \”msg\”:\”doe\”}”`) s, _ := strconv.Unquote(string(val)) err … Read more

Path variables in Spring WebSockets @SendTo mapping

Even though @MessageMapping supports placeholders, they are not exposed / resolved in @SendTo destinations. Currently, there’s no way to define dynamic destinations with the @SendTo annotation (see issue SPR-12170). You could use the SimpMessagingTemplate for the time being (that’s how it works internally anyway). Here’s how you would do it: @MessageMapping(“/fleet/{fleetId}/driver/{driverId}”) public void simple(@DestinationVariable String … Read more

JSON Web Token (JWT) with Spring based SockJS / STOMP Web Socket

Current Situation UPDATE 2016-12-13 : the issue referenced below is now marked fixed, so the hack below is no longer necessary which Spring 4.3.5 or above. See https://github.com/spring-projects/spring-framework/blob/master/src/docs/asciidoc/web/websocket.adoc#token-authentication. Previous Situation Currently (Sep 2016), this is not supported by Spring except via query parameter as answered by @rossen-stoyanchev, who wrote a lot (all?) of the Spring … Read more

Which websocket library to use with Node.js? [closed]

Getting the ball rolling with this community wiki answer. Feel free to edit me with your improvements. ws WebSocket server and client for node.js. One of the fastest libraries if not the fastest one. websocket-node WebSocket server and client for node.js websocket-driver-node WebSocket server and client protocol parser node.js – used in faye-websocket-node faye-websocket-node WebSocket … Read more