I am using webSocket with java 1.6 and HTML.
This is my reference example
https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example
When i go to http://localhost:8012/sessionLink/byteslounge/page.html
the error 404 is shown as below
WebSocket connection to 'ws://localhost:8012/sessionLink/websocket' failed: Error during WebSocket handshake: Unexpected response code: 404
Here is my code
Server Side
@ServerEndpoint("/websocket")
public class WebSocketTest {
...
}
HTML
<script type="text/javascript">
var webSocket =
new WebSocket('ws://localhost:8012/sessionLink/websocket');
...
</script>
Am i setting the WebSocket wrongly ?
localhost:Port/path setted in tomcat/@ServerEndpoint
尝试使用更高的jdk版本,java 1.6或更低版本不支持websocket。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.