Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Hey all, I'm looking to bring this module into my project. My project is using requirejs. Anytime I require the module, it tries to require "ws" and fails which fails the whole page. I looked at the src and seems its trying to require in module, exports, angular and ws. Has anyone got around this issue?
    Harish Gadiya
    how we can use angular websocket with typesscript anguarljs2 with unit testing
    Hamed Nourhani
    hi must i use socket.io alongside angular to connect server socket or there is a builltin functionality with ng?
    Pulkit Agarwal
    This message was deleted
    This message was deleted
    Bart Peperkamp
    Hi there, I managed to reconnect the socket session (in case of a server restart/error). The connection is 'open', however, i cannot get messages. Does anybody know what to do?
    Muhammad Aref
    I spent around 4 hours to figure out how to write a unit test, and I couldn't
    This is my service:
        function eventsStream (storage, $websocket) {
            const _collection = [];
            return {
                 * @param  {function} callback
                 * @return {object}
                connect (callback) {
                    // FIXME: we have to redirect to the config state
                    if (storage.get('streamConfig')) {
                        const wsUri = 'ws://localhost:8888/api';
                        const dataStream = $websocket(wsUri);
                        dataStream.onMessage(message => {
                            if (angular.isFunction(callback)) {
                    } else {
                        return 'You have to set the stream configuration.';
                    return {
                        collection: _collection
    The unit test:
        describe('Unit testing eventsStream service', () => {
            let $websocketBackend,
            beforeEach(angular.mock.module('ngWebSocket', 'ngWebSocketMock'));
            beforeEach(inject((_$websocketBackend_, _eventsStream_, _storage_) => {
                $websocketBackend = _$websocketBackend_;
                eventsStream = _eventsStream_;
                storage = _storage_;
                $websocketBackend.expectSend({data: JSON.stringify({test: true})});
            it('Should passes the collection to the connect callback is the configuration exists', () => {
                storage.set('streamConfig', {});
                eventsStream.connect(collection => {
    Muhammad Aref
    any help??
    Muhammad Aref
    I tried to use AMD (requireJS) to load angular-websocket file, but I get an error stating - Uncaught Error: Script error for "ws"
    I checked the source code of angular-websockets.js file, and seems the code tries to require['ws'] module
    I don't see any existence of 'ws' module. Any help would be appreciated here
    i just tried it and i didnt have any problems
    maybe use cdn?
    how can you open a connection with a different url?
    inside the controller
    also having trouble with unit testing with $websocketBackend. I can test the connect successfully, but I want to trigger the onOpen event handler so that I can test that functionality. how can I achieve a mocked successful websocket handshake using the mock library?
    Is Ok?

    Hi all!
    I am trying to make a small webapp, and was wondering what the best practice method was for getting initialization data when the socket makes the first connection? I currently have setup a .factoryto return a collection with a .send method. i,e

    .factory('WebSktData', function ($websocket) {
      <snip snip>
    var methods = {
                    collection: collection,
                     send: function (message) {
    return methods;

    What would be considered the correct way to pass a function to the onOpen and onError from the controller, and not directly in the factory?

    Jeremy Carlsten
    Anyone using this with typescript yet?

    I ask because I'm having issues with getting the typings setup. I've found a typings file for angular-websockets but when I try to compile my ts files I get the following error
    tsconfig.json generated: tsconfig.json

    typings/modules/angular-websocket/index.d.ts(23,22): error TS1110: Type expected.
    typings/modules/angular-websocket/index.d.ts(24,35): error TS1109: Expression expected.
    typings/modules/angular-websocket/index.d.ts(163,1): error TS1128: Declaration or statement expected.

    Hi there
    I'm looking to use angular-websocket but once I've install it and injecting it to my all app my unit test beforeEarch call are not... called, is someone have seen a similar issue?
    my bad, I just forget to add angular-websocket to karma imports
    sorry for the noise :D
    Ask, angular2-websocket support IPv6 access?
    Ask, angular2-websocket support IPv6 access?
    Saurabh Mishra
    Hi, can somebody give me pointers for using websocket with angular 4
    A general websocket question
    Is there any option to send data to client, without any request from client?
    yes use emit
    websockets is about events
    there are 4 events
    or you can use intervals
    Guys. Anyone here who can help me with adding a JWT Authorization header to the websocket connection string? There's a PR for it which I have transpiled but I dont know how to add it
    This is my current string which works on ws servers without needing JWT auth.
        var wsTransactions = $websocket('wss://frontend.smartloxs.io:8090/access/transactions', {
            reconnectIfNotNormalClose: false
    Claudio Pomo
    I'm using AngularWebSocket with angular-nvd3. I get a lot of error in console about Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
    How can I solve this?
    Is https://github.com/afrad/angular2-websocket the best alternate for using websockets in angular 5?
    I was using https://github.com/gdi2290/angular-websocket in Angular 1.x
    I`m using Angular universal and webpack compiler exactly like docs that angular published. But I faced many errors:
    ERROR Error: NotYetImplemented
    at Document.exports.nyi (webpack-internal:///./node_modules/domino/lib/utils.js:41:9)
    at CookieService.check (webpack-internal:///./node_modules/ngx-cookie-service/cookie-service/cookie.service.js:31:48)
    Could you please help me?
    Mateusz Mydlarz
    Hi guys, i try to enter angular-websocket documentation and i cant https://www.omniref.com/github/gdi2290/angular-websocket
    someone can help me?