WebSocket handshake: Unexpected response code: 404 -

后端 未结 2 1405
礼貌的吻别
礼貌的吻别 2021-01-14 08:54

I am learning about websockets and followed the instructions here: http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/HomeWebsocket/WebsocketHome.html

I\

相关标签:
2条回答
  • 2021-01-14 09:28

    The Error during the handshake happens, because Tomcat has its own api for websockets. Thus you might have added the JSR implementation or something similar as javax.websocket-api in your pom.xml there comes a conflict at runtime.

    Try to not export your Websocket-library to your webserver, thus it uses its own implementation.

    If you use maven, set the websocket dependency as provided:

    <!-- Provided Websocket API, because tomcat has its own implementation -->
    <dependency>
        <groupId>javax.websocket</groupId>
        <artifactId>javax.websocket-api</artifactId>
        <version>1.1</version>
        <scope>provided</scope>
    </dependency>
    
    0 讨论(0)
  • 2021-01-14 09:42

    I also had the same problem. Try removing the unwanted jars which contains websocket in your $JAVA_HOME/lib folder. and then add only what you are importing in serverendpoint file.

    0 讨论(0)
提交回复
热议问题