PatrickJS / angular-websocket

:arrow_upper_left: The missing Angular WebSocket module for connecting client applications to servers by @AngularClass
https://angularclass.github.io/angular-websocket
MIT License
1.22k stars 194 forks source link

Slow to response when make intensive connection request #120

Open iwknow opened 7 years ago

iwknow commented 7 years ago

In my app, I need to scan through 10 webSocket addresses to see which one is available regularly. Here is how I use the client:

var wsConn = $websocket('ws://mySite.com', null, {maxTimeout: WS_CONNECT_TIMEOUT});

wsConn.onError(function(event) {
                        // try another address});
                    wsConn.onOpen(function() {
                        // do something for success                    });
                    wsConn.onMessage(function(msg) {
                        // do something for receiving message
                    });

The first couple rounds of scan works alright. Either onError or onOpen will be triggered in 20ms. But after that, it become really slow. onError or onOpen are usually triggered after 2000ms. Even refresh the page doesn't help. If i open a new tab or restart browser, it works fine and becomes slow after couple rounds of scan.

I use Chrome.

Any idea? Thanks!