WebSocket In / OutBoundChannel' clientSession'还没有成立。考虑开始'这个容器

时间:2017-03-12 15:22:34

标签: spring-integration spring-websocket

我使用spring-integration-websocket来使用stompSubProtocol。

我的示例代码为' https://github.com/spring-projects/spring-integration/tree/master/spring-integration-websocket/src/main/java/org/springframework/integration/websocket'

我的代码几乎相同的示例代码。 但..我的代码导致以下错误..

"clientOutboundChannel-1" org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.websocket.outbound.WebSocketOutboundMessageHandler#1]; nested exception is java.lang.IllegalStateException: 'clientSession' has not been established. Consider to 'start' this container.
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:84)

我在xml中设置了int-websocket in / out-bound-channel。

    <beans:bean id="webSocketClient" class="org.mockito.Mockito" factory-method="mock">
        <beans:constructor-arg value="org.springframework.web.socket.client.WebSocketClient"></beans:constructor-arg>
    </beans:bean>

    <int-websocket:client-container id="clientWebSocketContainer"
                                client="webSocketClient"
                                uri="*"
                                uri-variables="ws,user"
                                send-buffer-size-limit="1000000"
                                send-time-limit="100"
                                origin="FOO"
                                phase="100">
</int-websocket:client-container>

<beans:bean id="stompSubProtocolHandler" class="org.springframework.web.socket.messaging.StompSubProtocolHandler">

   </beans:bean>

   <beans:bean id="passThruSubProtocolHandler"
      class="org.springframework.integration.websocket.support.PassThruSubProtocolHandler" >
      </beans:bean>


<beans:bean id="simpleMessageConverter"
      class="org.springframework.integration.support.converter.SimpleMessageConverter" > </beans:bean>

<beans:bean id="mapMessageConverter" class="org.springframework.integration.support.converter.MapMessageConverter"> </beans:bean> 


<int-websocket:inbound-channel-adapter id="customInboundAdapter" container="clientWebSocketContainer"
                                       auto-startup="false"
                                       payload-type="java.lang.Integer"
                                       protocol-handlers="passThruSubProtocolHandler"
                                       default-protocol-handler="stompSubProtocolHandler"
                                       message-converters="simpleMessageConverter,mapMessageConverter"
                                       merge-with-default-converters="true"
                                       channel="clientInboundChannel"
                                       error-channel="errorChannel"
                                       send-timeout="2000"
                                       phase="200" />

<int-websocket:outbound-channel-adapter id="defaultOutboundAdapter" container="serverWebSocketContainer" />

<int-websocket:outbound-channel-adapter id="customOutboundAdapter" container="clientWebSocketContainer"
                                        default-protocol-handler="stompSubProtocolHandler"
                                        protocol-handlers="passThruSubProtocolHandler"
                                        message-converters="simpleMessageConverter,mapMessageConverter"
                                        merge-with-default-converters="true"
                                        channel="clientOutboundChannel" />

<int:channel id="clientOutboundChannel" />

出了什么问题?

1 个答案:

答案 0 :(得分:0)

我认为你的模拟webSocketClient没有返回Session对象的问题。因此,容器认为这是致命的问题并且失败。