java - Websocket server using Netbeans and Tomcat 8 -


i'm having trouble accessing websocket server using netbeans , tomcat 8.0.9 (error during websocket handshake: unexpected response code: 404). here java code:

package websocketserver; import java.util.collections; import java.util.hashset; import java.util.set; import javax.websocket.session;  @javax.websocket.server.serverendpoint("/endpoint") public class websocketserver {     private static set<session> peers = collections.synchronizedset(new hashset<session>());          @javax.websocket.onmessage     public string onmessage(string message) {         return null;     }      @javax.websocket.onopen     public void onopen (session peer) {         peers.add(peer);     }      @javax.websocket.onclose     public void onclose (session peer) {         peers.remove(peer);     }     } 

javascript:

var wsuri = "ws://" + document.location.host + "/websocketserver/endpoint";  var websocket = new websocket(wsuri);  websocket.onerror = function(evt) { onerror(evt) };  function onerror(evt) {     console.log(evt);     writetoscreen('<span style="color: red;">error:</span> ' + evt.data); }  // testing purposes var output = document.getelementbyid("output"); websocket.onopen = function(evt) { onopen(evt) };  function writetoscreen(message) {     output.innerhtml += message + "<br>"; }  function onopen() {     writetoscreen("connected " + wsuri); } // end test functions 

i using java ee7 , read there issues tomcat 7 these have been resolved tomcat 8?

http 404 indicates resource not found. therefore requested uri has faulty.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -