ngxs / store

🚀 NGXS - State Management for Angular
http://ngxs.io
MIT License
3.54k stars 403 forks source link

WebSocket stream is killed after a WebSocketDisconnected action completes #977

Closed estelle0500 closed 5 years ago

estelle0500 commented 5 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ X ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => https://github.com/ngxs/store/blob/master/CONTRIBUTING.md
[ ] Other... Please describe:

Current behavior

Trying to use the WebSocket plugin to connect with my server. Once a WebSocketDisconnected action happens, the WebSocketSubject produces an error. Even if I try to reconnect by dispatching a ConnectWebSocket action afterwards, no more data comes through the subscription to WebSocketSubject as the stream has been killed.

Expected behavior

After reconnecting, the WebSocketSubject should continue to emit data sent from the server.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

The connection with the server may not be stable and I don't want to force the user to refresh the page (which would regenerate everything, including creating a new WebSocketSubject) to be able to see the new changes.

Environment


Libs:
- @angular/core version: 7.2.11
- @ngxs/store version: 3.4.1
- @ngxs/websocket-plugin version: 3.4.1


Browser:
- [ X ] Chrome (desktop) version 73.0.3683.86
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

Others:

markwhitfeld commented 5 years ago

Looking at the code in the websocket plugin this definitely seems to be an issue. @ngxs/core As part of fixing this we need to get the websocket tests working, reproduce the error and fix it.

arturovt commented 5 years ago

@estelle0500

I've published a PR that fixes that issue. Would you like to help me with your regression feedback if everything is ok or not? So we're able to add that fix to the 3.5.0 release.

P.S. I will notify you when this PR gets merged

arturovt commented 5 years ago

@estelle0500

The PR was merged. You can try it out by running:

yarn upgrade @ngxs/websocket-plugin@dev

The latest dev version is 3.4.3-dev.master-dad8ead

splincode commented 5 years ago

Released in 3.5.0