rstoyanchev / spring-websocket-portfolio

740 stars 443 forks source link

Broker auth information not sent properly by spring websocket #55

Closed samavedulark closed 9 years ago

samavedulark commented 9 years ago

Hi, iam using spring websockets and rabbitmq as relay broker. I created a user with login as 'test' and password as 'test123' for virtual host '\'. I am using jetty based java client for connecting to spring websocket server and sending stomp messages.

when running spring websocket without any login info. Spring websocket server is connected to rabbitmq and even jetty client can also connect.

when using custom login/passcode. config.enableStompBrokerRelay("/topic/","/queue/","/exchange/").setRelayHost("localhost").setSystemLogin("test").setSystemPasscode("test123"); It is not working. Spring websocket server is connected to rabbitmq, but jetty client fails to connect. Below is the stomp message. CONNECT accept-version:1.1,1.0 login:test passcode:test123

Below is the log, spring websocket is not using login "test", rather using 'guest'.

Below is the log. 2015-03-31 18:38:57,542 DEBUG o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties] 2015-03-31 18:38:57,542 DEBUG o.s.core.env.PropertySourcesPropertyResolver - Found key 'spring.liveBeansView.mbeanDomain' in [systemProperties] with type [String] and value '' 2015-03-31 18:38:57,571 INFO reactor.tcp.netty.NettyTcpClient - CONNECT: [id: 0x97bea05e, /3.204.21.160:49671 => /3.204.49.137:61613] 2015-03-31 18:38:57,579 DEBUG o.s.m.simp.stomp.StompBrokerRelayMessageHandler - Established TCP connection to broker in session 'stompRelaySystemSessionId' 2015-03-31 18:38:57,582 DEBUG o.s.messaging.simp.stomp.StompEncoder - Encoded STOMP command=CONNECT headers={accept-version=[1.1,1.2], login=[test], heart-beat=[10000,10000], passcode=[test123]} 2015-03-31 18:38:57,594 DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.noResourceLeakDetection: false 2015-03-31 18:38:57,611 INFO org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"] 2015-03-31 18:38:57,612 INFO org.apache.tomcat.util.net.NioSelectorPool - Using a shared selector for servlet write/read 2015-03-31 18:38:57,615 DEBUG o.s.messaging.simp.stomp.StompDecoder - Decoded [Payload byte[0]][Headers={simpMessageType=OTHER, stompCommand=CONNECTED, nativeHeaders={server=[RabbitMQ/3.3.4], heart-beat=[10000,10000], version=[1.2], session=[session-Cp4Z1WS2c3NCJMCH8KwcOA]}, id=93dc4a9d-2429-bded-0e82-32aed3e4ca54, timestamp=1427807337615}] 2015-03-31 18:38:57,619 INFO o.s.b.c.e.tomcat.TomcatEmbeddedServletContainer - Tomcat started on port(s): 8080/http 2015-03-31 18:38:57,623 INFO com.Main - Started Main in 16.481 seconds (JVM running for 18.872) 2015-03-31 18:38:57,630 DEBUG o.s.m.simp.stomp.StompBrokerRelayMessageHandler - Received message from broker in session 'stompRelaySystemSessionId' 2015-03-31 18:38:57,660 DEBUG o.s.m.simp.stomp.StompBrokerRelayMessageHandler - Publishing BrokerAvailabilityEvent (available) 2015-03-31 18:40:00,437 DEBUG o.s.messaging.simp.stomp.StompDecoder - Decoded [Payload byte[0]][Headers={simpMessageType=CONNECT, stompCommand=CONNECT, nativeHeaders={accept-version=[1.1,1.0], login=[test], passcode=[PROTECTED]}, stompCredentials=[PROTECTED], id=0f036604-273d-088a-ead4-5921fe47106c, timestamp=1427807400437}] 2015-03-31 18:40:00,440 DEBUG o.s.m.simp.stomp.StompBrokerRelayMessageHandler - Processing CONNECT (total connected=1) 2015-03-31 18:40:00,590 INFO reactor.tcp.netty.NettyTcpClient - CONNECT: [id: 0x675d7085, /3.204.21.160:49699 => /3.204.49.137:61613] 2015-03-31 18:40:00,591 DEBUG o.s.m.simp.stomp.StompBrokerRelayMessageHandler - Established TCP connection to broker in session '0' 2015-03-31 18:40:00,592 DEBUG o.s.messaging.simp.stomp.StompEncoder - Encoded STOMP command=CONNECT headers={accept-version=[1.1,1.0], login=[guest], passcode=[test123]} 2015-03-31 18:40:00,597 DEBUG o.s.messaging.simp.stomp.StompDecoder - Decoded [Payload byte[32]][Headers={simpMessageType=OTHER, stompCommand=ERROR, nativeHeaders={content-length=[32], content-type=[text/plain], message=[Bad CONNECT], version=[1.0,1.1,1.2]}, contentType=text/plain, id=7830eefd-6c3a-5047-faae-cb1a284586df, timestamp=1427807400596}] 2015-03-31 18:40:00,597 DEBUG o.s.m.simp.stomp.StompBrokerRelayMessageHandler - Received message from broker in session '0' 2015-03-31 18:40:00,601 DEBUG o.s.messaging.simp.stomp.StompEncoder - Encoded STOMP command=ERROR headers={content-length=[32], content-type=[text/plain], message=[Bad CONNECT], version=[1.0,1.1,1.2]} 2015-03-31 18:40:00,621 DEBUG o.s.w.s.adapter.standard.StandardWebSocketSession - Closing WebSocket session id=0 2015-03-31 18:40:00,630 DEBUG o.s.w.s.handler.LoggingWebSocketHandlerDecorator - Connection closed for WebSocket session id=0, CloseStatus [code=1002, reason=null]

Thanks Ravi S

samavedulark commented 9 years ago

I missed it. need to add client login and passcode.