3
votes

Couldn't find any other questions related to this specific error.

I can't seem to hook up my Spring Boot WebSocket demo project with RabbitMQ. Note that everything works fine when using the "simple" broker, but when hooking up the stomp broker with Rabbit, I get the following error (keeps trying to reconnect):

Java HotSpot(TM) Client VM warning: You have loaded library /tmp/libnetty-transport-native-epoll8916930274033685449.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
2016-03-07 22:35:13.993  INFO 4047 --- [           main] o.s.m.s.s.StompBrokerRelayMessageHandler : Started.
2016-03-07 22:35:14.045  INFO 4047 --- [eactor-tcp-io-1] r.io.net.impl.netty.tcp.NettyTcpClient   : CONNECTED: [id: 0x034a269f, /127.0.0.1:39955 => /127.0.0.1:25672]
2016-03-07 22:35:14.151  INFO 4047 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-03-07 22:35:14.158  INFO 4047 --- [           main] com.chat.ChatApplication                 : Started ChatApplication in 8.921 seconds (JVM running for 17.336)
2016-03-07 22:35:21.028  INFO 4047 --- [eactor-tcp-io-1] r.io.net.impl.netty.tcp.NettyTcpClient   : CLOSED: [id: 0x034a269f, /127.0.0.1:39955 :> /127.0.0.1:25672]
2016-03-07 22:35:21.030  INFO 4047 --- [eactor-tcp-io-1] r.io.net.impl.netty.tcp.NettyTcpClient   : Failed to connect to /127.0.0.1:25672. Attempting reconnect in 5000ms.

Just to be sure I'm pointing at the right point, I run:

matthew@matthew ~/code/chat $ epmd -names
epmd: up and running on port 4369 with data:
name rabbit at port 25672

Here's my WebSocketConfig:

package com.chat.shared.websocket;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import com.chat.user.services.UserPresenceService;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableStompBrokerRelay("/topic", "/queue").setRelayPort(25672);
        config.setApplicationDestinationPrefixes("/app");
    }

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

    @Bean
    public UserPresenceService presenceChannelInterceptor() {
      return new UserPresenceService();
    }

  @Override
  public void configureClientInboundChannel(ChannelRegistration registration) {
      registration.setInterceptors(presenceChannelInterceptor());
  }

  @Override
  public void configureClientOutboundChannel(ChannelRegistration registration) {
      registration.taskExecutor().corePoolSize(8);
      registration.setInterceptors(presenceChannelInterceptor());
  }

}

and finally my dependencies:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.chat</groupId>
  <artifactId>chat</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>chat</name>

  <description>WebSocket Project</description>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.2.RELEASE</version>
    <relativePath />
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.session</groupId>
      <artifactId>spring-session-data-redis</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-messaging</artifactId>
    </dependency>

    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-core</artifactId>
    </dependency>

    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-net</artifactId>
    </dependency>

    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.0.34.Final</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-amqp</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectreactor</groupId>
        <artifactId>reactor-tcp</artifactId>
        <version>1.0.0.RELEASE</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>

I have a feeling my problem has to do with the netty/reactor dependencies I'm bringing in. Any input is appreciated.

1
The netty version looks good, but I don't think that you need reactor-tcp at all. From other side the Reactor dependency really should be in version like 2.0.7.RELEASE.Artem Bilan
@ArtemBilan thanks for the suggestions. Unfortunately, the same reconnect error keeps happening. I also tried to use ports 61613 and 61614 but had no success. Note that I've installed a vanilla rabbitmq from the install instructions on the website :(Matthew Vita
M-m-m. Have you enabled the STOMP plugin there at all? rabbitmq.com/stomp.htmlArtem Bilan
@ArtemBilan that was the problem! rabbitmq-plugins enable rabbitmq_stomp fixed the issue. Please submit your comment as an answer!Matthew Vita

1 Answers

7
votes

First of all you really should be consistent with the Spring Framework (Boot) dependencies and don't use Reactor 1.0.0, but exactly the latest 2.0.7.RELEASE.

Not sure from here that you need reactor-tcp at all...

Regarding RabbitMQ part. You should be sure that you really have installed the STOMP plugin: https://www.rabbitmq.com/stomp.html.

Note: the default STOMP port is 61613.