Spring-cloud-sleuth: Exception when connect to a Websocket

Created on 13 May 2016  路  11Comments  路  Source: spring-cloud/spring-cloud-sleuth

I'm using Spring Cloud Sleuth in some projects and everything is working well. But in a project where I have a websocket, an exception is thrown when connected to the websocket.

To simulate the error, clone the spring websocket demo app:
https://github.com/spring-guides/gs-messaging-stomp-websocket

After just include the dependency: (Without the dependency everything works)

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
            <version>1.0.0.RELEASE</version>
        </dependency>

After run the application, connect to the websocket, you will see the exception:

Exception in thread "clientInboundChannel-2" org.springframework.messaging.MessageDeliveryException: Failed to handle GenericMessage [...]; nested exception is java.lang.IllegalStateException: No header accessor (not using the SimpMessagingTemplate?): GenericMessage [...]

Caused by: java.lang.IllegalStateException: No header accessor (not using the SimpMessagingTemplate?): GenericMessage [...]
at org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler.handleMessageInternal(SimpleBrokerMessageHandler.java:228)
    at org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler.handleMessage(AbstractBrokerMessageHandler.java:238)
    at org.springframework.messaging.support.ExecutorSubscribableChannel$SendTask.run(ExecutorSubscribableChannel.java:135)
    ... 3 more
bug

Most helpful comment

Should be fixed in Spring 4.2.7 according the the Spring ticket above.

All 11 comments

@dsyer this issue is same what I raised few months back. This is related to sending stomp based messages over websocet. If you remember few months back you removed some Stomp related interceptor and i claim it won't work. I will attach more detail wrn have access to Laptop.

I'm interested in why it doesn't work in Spring Websocket land. See here: https://jira.spring.io/browse/SPR-14279.

Should be fixed in Spring 4.2.7 according the the Spring ticket above.

@gauravrmazra , @rafaelhz does this work for you?

@marcingrzejszczak We are not using this feature(STOMP messages) anymore.

It doesn't work for me. I always get "java.lang.IllegalStateException: No header accessor in GenericMessage" when server sends CONNECT_ACK message. Sleuth version is 1.0.9.RELEASE and spring version 4.3.3.

@garyrussell @mbogoevici ^^ any ideas guys about this? @ArthurasJ can you post the whole stacktrace?

@marcingrzejszczak This would need to be reproduced locally again, I suppose. Off the top of my head, there could still be an issue with the ChannelInterceptors (even if the Spring issue was fixed in the mean time).

I will post my stacktrace in two days. But I've noticed, that this problem occurs, when MessageBuilder method build() creates new GenericMessage with different headers type. It creates it because headerAccessor.isModified() returns true. If I force it to return "this.originalMessage" everything seems to be working fine. Of course this doesn't explain the reason, why this happens.

10:47:55.078 [?] [mobSignatureIdp] [clientOutboundChannel-11] DEBUG org.springframework.web.socket.messaging.SubProtocolWebSocketHandler - Failed to send message to client in WebSocketServerSockJsSession[id=n4fit3fu]: GenericMessage [payload=byte[0], headers={simpMessageType=CONNECT_ACK, X-B3-ParentSpanId=15cd31c931fbd527, X-Message-Sent=true, messageSent=true, spanName=message:ExecutorSubscribableChannel[clientOutboundChannel], spanTraceId=15cd31c931fbd527, spanId=9d5f5b993d96d7aa, spanParentSpanId=15cd31c931fbd527, X-Span-Name=message:ExecutorSubscribableChannel[clientOutboundChannel], X-B3-SpanId=9d5f5b993d96d7aa, simpConnectMessage=GenericMessage [payload=byte[0], headers={simpMessageType=CONNECT, simpSessionAttributes={}, simpHeartbeat=[J@1abba77a, X-Message-Sent=true, messageSent=true, spanName=message:ExecutorSubscribableChannel[clientInboundChannel], spanTraceId=15cd31c931fbd527, spanId=15cd31c931fbd527, stompCommand=CONNECT, nativeHeaders={accept-version=[1.1,1.0], heart-beat=[10000,10000]}, X-Span-Name=message:ExecutorSubscribableChannel[clientInboundChannel], X-B3-SpanId=15cd31c931fbd527, currentSpan=[Trace: 15cd31c931fbd527, Span: 15cd31c931fbd527, Parent: null, exportable:true], X-B3-Sampled=1, X-B3-TraceId=15cd31c931fbd527, id=62b199dc-8d65-c3ea-653b-5635a9a157d7, X-Current-Span=[Trace: 15cd31c931fbd527, Span: 15cd31c931fbd527, Parent: null, exportable:true], spanSampled=1, simpSessionId=n4fit3fu, timestamp=1476085675073}], currentSpan=[Trace: 15cd31c931fbd527, Span: 9d5f5b993d96d7aa, Parent: 15cd31c931fbd527, exportable:true], X-B3-Sampled=1, X-B3-TraceId=15cd31c931fbd527, id=efa4f587-d3f3-cdfd-4020-c7a33e10eff3, X-Current-Span=[Trace: 15cd31c931fbd527, Span: 9d5f5b993d96d7aa, Parent: 15cd31c931fbd527, exportable:true], spanSampled=1, simpSessionId=n4fit3fu, timestamp=1476085675076}]
java.lang.IllegalStateException: No header accessor in GenericMessage [payload=byte[0], headers={simpMessageType=CONNECT_ACK, X-B3-ParentSpanId=15cd31c931fbd527, X-Message-Sent=true, messageSent=true, spanName=message:ExecutorSubscribableChannel[clientOutboundChannel], spanTraceId=15cd31c931fbd527, spanId=9d5f5b993d96d7aa, spanParentSpanId=15cd31c931fbd527, X-Span-Name=message:ExecutorSubscribableChannel[clientOutboundChannel], X-B3-SpanId=9d5f5b993d96d7aa, simpConnectMessage=GenericMessage [payload=byte[0], headers={simpMessageType=CONNECT, simpSessionAttributes={}, simpHeartbeat=[J@1abba77a, X-Message-Sent=true, messageSent=true, spanName=message:ExecutorSubscribableChannel[clientInboundChannel], spanTraceId=15cd31c931fbd527, spanId=15cd31c931fbd527, stompCommand=CONNECT, nativeHeaders={accept-version=[1.1,1.0], heart-beat=[10000,10000]}, X-Span-Name=message:ExecutorSubscribableChannel[clientInboundChannel], X-B3-SpanId=15cd31c931fbd527, currentSpan=[Trace: 15cd31c931fbd527, Span: 15cd31c931fbd527, Parent: null, exportable:true], X-B3-Sampled=1, X-B3-TraceId=15cd31c931fbd527, id=62b199dc-8d65-c3ea-653b-5635a9a157d7, X-Current-Span=[Trace: 15cd31c931fbd527, Span: 15cd31c931fbd527, Parent: null, exportable:true], spanSampled=1, simpSessionId=n4fit3fu, timestamp=1476085675073}], currentSpan=[Trace: 15cd31c931fbd527, Span: 9d5f5b993d96d7aa, Parent: 15cd31c931fbd527, exportable:true], X-B3-Sampled=1, X-B3-TraceId=15cd31c931fbd527, id=efa4f587-d3f3-cdfd-4020-c7a33e10eff3, X-Current-Span=[Trace: 15cd31c931fbd527, Span: 9d5f5b993d96d7aa, Parent: 15cd31c931fbd527, exportable:true], spanSampled=1, simpSessionId=n4fit3fu, timestamp=1476085675076}]
    at org.springframework.web.socket.messaging.StompSubProtocolHandler.getStompHeaderAccessor(StompSubProtocolHandler.java:465) ~[spring-websocket-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.socket.messaging.StompSubProtocolHandler.handleMessageToClient(StompSubProtocolHandler.java:383) ~[spring-websocket-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:338) [spring-websocket-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.messaging.support.ExecutorSubscribableChannel$SendTask.run(ExecutorSubscribableChannel.java:135) [spring-messaging-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_66]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_66]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_66]

There's another assumption in Spring Core. I raised another issue: https://jira.spring.io/browse/SPR-14791.

Was this page helpful?
0 / 5 - 0 ratings