Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    telvin
    @telvin
    WebSocket connection to 'ws://abc.com' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
    MILLER/F
    @millerf
    Guys, in the presentation of the WebsocketMock, there is a parenthesis missing:
    var $websocketBackend;
    beforeEach(angular.mock.module('ngWebSocket', 'ngWebSocketMock');
    MILLER/F
    @millerf
    Guys, I really have trouble creating tests.

    describe('Websocket', function () {

    //load module
    beforeEach(module('mozaik'));

    var $websocketBackend, createController;
    beforeEach(angular.mock.module('ngWebSocket', 'ngWebSocketMock'));

    beforeEach(inject(function ($websocketBackend) {
    $websocketBackend = $websocketBackend;
    $websocketBackend.mock();
    $websocketBackend.expectConnect('ws://localhost:1245/api');
    $websocketBackend.expectSend({data: JSON.stringify({test: true})});

    }));

    beforeEach(inject(function ($injector) {
    // The $controller service is used to create instances of controllers
    var $service = $injector.get('$service');
    createController = function () {
    return $service('mzksWebsocket');
    };
    }));

    it(’test1', function () {
    var mzksWebsocket = createController();
    //some test
    });

    ->failed to instantiate module ngWebSocketMock due to:
    Error: [$injector:nomod] Module 'ngWebSocketMock' is not available! You either misspelled the module name or forgot to load it. If registering a module ensu
    MILLER/F
    @millerf
    I fixed it.
    Benoit LeBlanc
    @beleblanc
    Hi there, Is there a quick way to find out if your socket is connected?
    nevermind, looked in source for readyStates :smile:
    Benoit LeBlanc
    @beleblanc
    Is this library still bein maintained though?
    Diego Benjamín Aguilar Aguilar
    @diegoaguilar
    @beleblanc I guess AngularClass/angular-websocket@88b6e88
    Benoit LeBlanc
    @beleblanc
    Will there be a new npm package soon with the latest merge as it resolves an issue I was having with webpack
    roelleor
    @roelleor
    Hi there, does anybody know about an angular2 version of websocket?
    MILLER/F
    @millerf
    It should be compatible, shouldn’t it?
    Antonio Troina
    @thoeni
    Hi guys, a quick question: I'm missing what the autoApply function should do. After around 60 seconds I see in my console.log this message: "angular.js:26309 Uncaught ReferenceError: autoApply is not defined" and my front-end stops receiving messages from the websocket server... any idea?
    nthibert
    @nthibert
    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
    @harishgadiya
    how we can use angular websocket with typesscript anguarljs2 with unit testing
    Hamed Nourhani
    @hamednourhani
    hi must i use socket.io alongside angular to connect server socket or there is a builltin functionality with ng?
    Pulkit Agarwal
    @pulkit21
    This message was deleted
    This message was deleted
    Bart Peperkamp
    @bartpeperkamp
    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
    @LeoAref
    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 => {
                            _collection.push(JSON.parse(message.data));
    
                            if (angular.isFunction(callback)) {
                                callback(_collection);
                            }
                        });
                    } else {
                        return 'You have to set the stream configuration.';
                    }
    
                    return {
                        collection: _collection
                    };
                }
            };
        }
    The unit test:
        describe('Unit testing eventsStream service', () => {
            let $websocketBackend,
                eventsStream,
                storage;
    
            beforeEach(module('mcp.gogo.services'));
            beforeEach(angular.mock.module('ngWebSocket', 'ngWebSocketMock'));
    
            beforeEach(inject((_$websocketBackend_, _eventsStream_, _storage_) => {
                $websocketBackend = _$websocketBackend_;
                eventsStream = _eventsStream_;
                storage = _storage_;
    
                $websocketBackend.mock();
                $websocketBackend.expectConnect('ws://localhost:8888/api');
                $websocketBackend.expectSend({data: JSON.stringify({test: true})});
                $websocketBackend.mockSend();
            }));
    
            it('Should passes the collection to the connect callback is the configuration exists', () => {
                storage.set('streamConfig', {});
    
                eventsStream.connect(collection => {
                    console.log(collection);
                });
    
                $websocketBackend.flush();
            });
        });
    Muhammad Aref
    @LeoAref
    any help??
    Muhammad Aref
    @LeoAref
    ??
    @/all
    innovation-stack
    @innovation-stack
    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
    piux
    @piux
    did
    well
    i just tried it and i didnt have any problems
    maybe use cdn?
    piux
    @piux
    how can you open a connection with a different url?
    inside the controller
    peffreycollins
    @peffreycollins
    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?
    chenhui3344
    @chenhui3344
    Is Ok?
    Ash
    @ashthespy

    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) {
                        dataStream.send(JSON.stringify(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
    @JeremyCarlsten
    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.

    Steeve
    @WnP
    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?
    Steeve
    @WnP
    my bad, I just forget to add angular-websocket to karma imports
    sorry for the noise :D
    mbw42
    @mbw42
    Ask, angular2-websocket support IPv6 access?
    Ask, angular2-websocket support IPv6 access?
    Saurabh Mishra
    @muditsaurabh
    Hi, can somebody give me pointers for using websocket with angular 4
    {{Wishnu}}
    @V5hnu_twitter
    A general websocket question
    Is there any option to send data to client, without any request from client?
    piux
    @piux
    yes use emit
    websockets is about events