wilk / ng-websocket

AngularJS HTML5 WebSocket powerful library
MIT License
267 stars 78 forks source link

Protocol Chrome error #11

Closed baki250 closed 8 years ago

baki250 commented 9 years ago

WebSocket connection to 'ws://apilocal.ws.com:8887/' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received

Has anyone had this issue?

imogenkinsman commented 9 years ago

I've been dealing with the same issue - will make a pull request tonight. The problem is that the websocket is being created with an empty protocol argument (not sure if this works with other browsers, but chrome blows up for me).

n3gotium commented 9 years ago

Could you update bower version with that fix, please. I have had to spent quite a time trying to figure out why websocket has stoped working after switching to the bower version.

saurav2k4u commented 9 years ago

I am using the bower version, and the error keeps coming up. May i request the author to update the bower version (though it works with git version).

This is a nice wrapper and i am keen in using it.

Bclayson commented 9 years ago

You can fix this by passing in "subprotocol: 'base46'".

Don't ask me why this works. It just does. Maybe someone can figure it out and make a pull request so that it works with the intended 'protocols' property. ::shrug::

n3gotium commented 9 years ago

Well, what I do in order to fix it is just passing an empty array to the "protocols" property.

jfranki commented 9 years ago

With two identical projects, the one with ng-websocket bower version 0.2.1 throws the error and the one with the actual git version works. Until the version is bumped the bower version is unusable at least in Chrome.

me.$$ws = cfg.mock ? new $$mockWebsocket(cfg.mock, $http) : new WebSocket(cfg.url, cfg.protocols);

was changed to

if (cfg.mock) {
    me.$$ws = new $$mockWebsocket(cfg.mock, $http);
}
else if (cfg.protocols) {
    me.$$ws = new WebSocket(cfg.url, cfg.protocols);
}
else {
    me.$$ws = new WebSocket(cfg.url);
}
rudzikdawid commented 9 years ago

Just put small change to your bower.json file:

  "dependencies": {
    "ng-websocket": "git://github.com/wilk/ng-websocket.git#master"
  }

now you have latest version in bower_components or put:

  "dependencies": {
    "ng-websocket": "git://github.com/wilk/ng-websocket.git#ecbdac7ec14aa0e47b9dad4cb29152c658ddaad3"
  }

now you have version with this particular commit

jcollum commented 8 years ago

The fix for this (for me) was: var ws = $websocket.$new({'url': 'ws://localhost:8000/foo', 'protocols': [], 'subprotocols': ['base46'] });; subprotocols might not be needed...

wilk commented 8 years ago

This project is no longer mainteined. Sorry.