Skip to content

Server sends SEND stomp frames back to the client instead of MESSAGE frames [SPR-10930] #15558

@spring-projects-issues

Description

@spring-projects-issues

Ralph Schaer opened SPR-10930 and commented

Tested with:
spring-websocket-4.0.0.BUILD-20130914.053543-227
spring-messaging-4.0.0.BUILD-20130920.184120-127.jar

In the following scenario the server sends stomp SEND messages back to the client. But SEND is a client frame according to the specification (http://stomp.github.io/stomp-specification-1.1.html#SEND)
Instead the server should send MESSAGE frames back to the client.

The following example does not contain any application code. Just two configuration classes.

public class DispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

  @Override
  protected Class<?>[] getRootConfigClasses() {
    return null;
  }

  @Override
  protected Class<?>[] getServletConfigClasses() {
    return new Class<?>[] { WebConfig.class };
  }

  @Override
  protected String[] getServletMappings() {
    return new String[] { "/chatdemo/*" };
  }
}
@Configuration
@EnableWebMvc
@EnableWebSocketMessageBroker
public class WebConfig extends WebMvcConfigurerAdapter implements WebSocketMessageBrokerConfigurer {

  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("index.html");
  }

  @Override
  public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    configurer.enable();
}

  @Override
  public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chathandler").withSockJS();
  }

  @Override
  public void configureMessageBroker(MessageBrokerConfigurer configurer) {
    configurer.enableSimpleBroker("/queue/");
  }

}

On the client side we have this code:

var sock = new SockJS('/chatdemo/chathandler');
var stompClient = Stomp.over(sock);

stompClient.connect('', '', function(frame) {	
	stompClient.subscribe("/queue/chatmessage", function(msg) {
		....
	});
});

and a few lines later the application sends something to the server

stompClient.send("/queue/chatmessage", {}, JSON.stringify(....));

Message flow:

Client sends CONNECT   --> OK
Server sends CONNECTED  --> OK
Client sends SUBSCRIBE and SEND  --> OK
Server sends SEND   --> Not OK. This has to be a MESSAGE frame.

It looks like the problem is in the method sendMessageToSubscribers(..) in the class org.springframework.messaging.simp.handler.SimpleBrokerMessageHandler


Affects: 4.0 M3

Attachments:

Referenced from: commits 6ddacdc

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions