【问题标题】:openshift + spring websocketopenshift + 弹簧 websocket
【发布时间】:2015-07-02 14:46:59
【问题描述】:

我是 openshift 新手,目前正在尝试在那里设置我的 websocket 应用程序,但遇到了一些问题。当我尝试连接到

ws://app-domain.rhcloud.com:8000/path

我得到以下异常:

Caused by: java.lang.IllegalArgumentException: No 'javax.websocket.server.Server Container' ServletContext attribute. Are you running in a Servlet container that
supports JSR-356?
    at org.springframework.util.Assert.notNull(Assert.java:112)
    at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.getContainer(AbstractStandardUpgradeStrategy.java:68)
    at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:83)
    at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:46)
    at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.getSupportedExtensions(AbstractStandardUpgradeStrategy.java:88)
    at org.springframework.web.socket.server.support.DefaultHandshakeHandler.doHandshake(DefaultHandshakeHandler.java:214)
    at org.springframework.web.socket.server.support.WebSocketHttpRequestHandler.handleRequest(WebSocketHttpRequestHandler.java:127)
    ... 25 more

当我在本地运行应用程序时,使用以下网址一切正常:

ws://localhost:8090/path

对于这两种情况,我都使用 Tomcat 7。 弹簧配置:

<websocket:handlers allowed-origins="*">
    <websocket:mapping path="/fight-core" handler="webSocketHandler"/>
    <websocket:handshake-interceptors>
        <ref bean="webSocketHandshakeInterceptor"/>
    </websocket:handshake-interceptors>
</websocket:handlers>

我也试过在我的 pom.xml 中使用 websocket-api 依赖,但没有它

温馨提示

【问题讨论】:

    标签: spring websocket openshift spring-websocket


    【解决方案1】:

    显然不是 Spring 也不是 Tomcat,而是 Openshift 的路由层;看起来 websocket 支持仍处于试验阶段,请参阅: * a blog post from 2012 explaining the situation * Openshift official documentation

    对于普通的 WebSocket 连接 (ws://),请求被定向到端口 8000,而 WebSocket 安全连接 (wss://) 使用端口 8443,如 如下例所示:http://example.example.com:8000 https://example.example.com:8443

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-04
      • 2017-08-23
      • 2017-05-15
      • 1970-01-01
      • 2022-10-04
      • 2021-11-24
      • 2017-12-22
      • 2016-03-23
      相关资源
      最近更新 更多