ClusterWS-Client-JS icon indicating copy to clipboard operation
ClusterWS-Client-JS copied to clipboard

'disconnect' event is not triggered

Open ramjak opened this issue 6 years ago • 3 comments

Submitting

  • [x] Bug
  • [ ] Question
  • [ ] Suggetion
  • [ ] Other

Using:

  1. ClusterWS v3.1.1
  2. OS Ubuntu 18.04

Desc: 'disconnect' event is not triggered after the socket is closed. After I check the disconnect event is missing in the event list in the EventEmitter.

17:20:33.702 emit {error: ƒ, connect: ƒ, response: ƒ, disconnect} connect
17:20:33.718 subscribe to to channel
17:20:33.719 status$: ON
17:20:33.764 emit {error: ƒ, connect: ƒ, response: ƒ} response

I've tried to check if off in the EventEmitter is triggered, but it's not.

ramjak avatar Feb 14 '19 10:02 ramjak

Ohh that is interesting, i will check it out today.

goriunov avatar Feb 14 '19 20:02 goriunov

@ramjak i have run tests locally and seems like everything works correctly

First is calling close socket from frontend (works ok)

   <script>
        let socket = new ClusterWS({
            url: 'ws://localhost:3000'
        });

        socket.on("disconnect", (code, error) => {
            console.log("Should be called", code, error);
        });

        setTimeout(() => {
            console.log("Close socket");
            socket.disconnect();
        }, 5000)
    </script>

and second i tied calling close from back end (also works ok)

   <script>
        let socket = new ClusterWS({
            url: 'ws://localhost:3000'
        });

        socket.on("disconnect", (code, error) => {
            console.log("Should be called", code, error);
        });
    </script>

goriunov avatar Feb 15 '19 00:02 goriunov

Can you please provide your code which does not work.

goriunov avatar Feb 15 '19 00:02 goriunov