I have a Spring Boot application which I am deploying to a Cloud Foundry instance (BlueMix). I have bound a CloudAMQP instance to the application and would like to use it for sending my STOMP meessages. I have not been able to properly configure my StompBrokerRelayRegistration class to successfully connect the RabbitMQ instance in CloudAMP. I have called
config.enableStompBrokerRelay("/topic", "/queue");
But this tried to connect to localhost. I thought it might try to use my org.springframework.amqp.rabbit.connection.ConnectionFactory bean but I guess not.
I then tried to call setRelayHost, setRelayPort, setSystemLogin, setSystemPasscode, and setVirtualHost with the information in VCAP_SERVICES. After doing this Spring seems to try to connect to the RabbitMQ instance but based on the logs the connection is closed immediately saying
Connection reset by peer
. Anyone have any idea what I might be doing wrong?
Update
Aparently I was using the wrong port. Using port 5672 causes the behavior where the connection is closed immediately. If I use port 61613 the connection appears to be established. However once the browser tries to go and establish the websocket the following exception is thrown
java.lang.IllegalStateException: The WebSocket session has been closed and no method (apart from close()) may be called on a closed session
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.apache.tomcat.websocket.WsSession.checkState(WsSession.java:649)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.apache.tomcat.websocket.WsSession.getUserPrincipal(WsSession.java:578)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.adapter.standard.StandardWebSocketSession.getPrincipal(StandardWebSocketSession.java:123)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.getPrincipal(WebSocketServerSockJsSession.java:73)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.messaging.StompSubProtocolHandler.afterSessionEnded(StompSubProtocolHandler.java:364)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.clearSession(SubProtocolWebSocketHandler.java:352)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.afterConnectionClosed(SubProtocolWebSocketHandler.java:347)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.handler.WebSocketHandlerDecorator.afterConnectionClosed(WebSocketHandlerDecorator.java:85)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.afterConnectionClosed(LoggingWebSocketHandlerDecorator.java:71)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.afterConnectionClosed(ExceptionWebSocketHandlerDecorator.java:89)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.close(AbstractSockJsSession.java:289)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.handler.WebSocketSessionDecorator.close(WebSocketSessionDecorator.java:158)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.messaging.StompSubProtocolHandler.handleMessageToClient(StompSubProtocolHandler.java:287)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:306)
2014-05-14T22:17:53.70-0400 [App/0] OUT at org.springframework.messaging.support.ExecutorSubscribableChannel$1.run(ExecutorSubscribableChannel.java:70)
2014-05-14T22:17:53.70-0400 [App/0] OUT at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
2014-05-14T22:17:53.70-0400 [App/0] OUT at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
2014-05-14T22:17:53.70-0400 [App/0] OUT at java.lang.Thread.run(Thread.java:745)
Above this I see this warning
2014-05-14T22:17:53.69-0400 [App/0] OUT 2014-05-15 02:17:53.698 WARN 31 --- [tboundChannel-1] o.s.w.s.m.SubProtocolWebSocketHandler : Ignoring protocol in WebSocket session after failure to obtain it: java.lang.IllegalStateException: The WebSocket session has been closed and no method (apart from close()) may be called on a closed session
2014-05-14T22:17:53.70-0400 [App/0] OUT 2014-05-15 02:17:53.709 ERROR 31 --- [tboundChannel-1] w.s.h.ExceptionWebSocketHandlerDecorator : Unhandled error for ExceptionWebSocketHandlerDecorator [delegate=LoggingWebSocketHandlerDecorator [delegate=org.springframework.web.socket.messaging.SubProtocolWebSocketHandler@646eb571]]
Anyone have an idea on what is going wrong here?