java - WebSocket in Javascript not connecting to servlet -
i trying use javascript websockets connect java servlet, onerror function being called, , not providing information. javascript:
var websocket = new websocket('ws://localhost:8080/test'); websocket.onerror = function(event) { onerror(event); }; websocket.onclose = function(event) { onclose(event); }; websocket.onopen = function(event) { onopen(event); }; websocket.onmessage = function(event) { onmessage(event); }; function onclose(event) { var code = event.code; var reason = event.reason; var wasclean = event.wasclean; alert(code + "; " + reason + "; " + wasclean); } function onmessage(event) { //do stuff } function onopen(event) { websocket.send('opening socket'); } function onerror(event) { alert(event.message); }
for servlet, have
@serverendpoint("/test") public class transcodersnsservlet extends httpservlet { ... }
the useful error codes i've been able find event.code = 1006, event.wasclean = false. browser using supports websockets. trying run on elasticbeanstalk. appreciated
Comments
Post a Comment