Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): add ws heartbeat #2404

Merged
merged 4 commits into from Jan 31, 2020
Merged

Conversation

knagaitsev
Copy link
Collaborator

@knagaitsev knagaitsev commented Jan 29, 2020

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Yes, and also restructured the test file for WebsocketServer slightly

Motivation / Use-Case

Add ws heartbeat

#2403 (need investigate client code)

Breaking Changes

None

Additional Info

@codecov
Copy link

codecov bot commented Jan 29, 2020

Codecov Report

Merging #2404 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2404   +/-   ##
======================================
  Coverage    93.8%   93.8%           
======================================
  Files          34      34           
  Lines        1307    1307           
  Branches      371     371           
======================================
  Hits         1226    1226           
  Misses         79      79           
  Partials        2       2

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46c3691...a194452. Read the comment docs.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knagaitsev
Copy link
Collaborator Author

Good job, what about client? Second part of https://github.com/websockets/ws#how-to-detect-and-close-broken-connections

@evilebottnawi Good point. However, we are using a native browser WebSocket (https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API), not a ws client WebSocket. The browser WebSocket seems to not have a ping method, nor can it listen for pings from the server (https://stackoverflow.com/questions/10585355/sending-websocket-ping-pong-frame-from-browser). Do you think I should just implement a "ping" message which is not a real ping but accomplishes the same task?

@alexander-akait
Copy link
Member

Hm, we need investigate that, i will look at that in near future

@alexander-akait
Copy link
Member

I looked and tested the solution, it works well, I’m not sure about the client code, but the current code can be merged, a little later I will investigate the client in more detail

@alexander-akait alexander-akait merged commit 1a7c827 into webpack:master Jan 31, 2020
@gamedev8
Copy link

@Loonride This is great, but I think you will still eventually get a timeout if you are stepping through your code in the browser dev tools. The browser is holding up the whole application so the client code cannot communicate with the server. You can easily test this by setting a breakpoint and wait until it times out.

If that is true, then maybe the client code needs to be hardened as well. It should be able to reconnect to the server if it detects that the connection is broken.

@knagaitsev
Copy link
Collaborator Author

@Loonride This is great, but I think you will still eventually get a timeout if you are stepping through your code in the browser dev tools. The browser is holding up the whole application so the client code cannot communicate with the server. You can easily test this by setting a breakpoint and wait until it times out.

If that is true, then maybe the client code needs to be hardened as well. It should be able to reconnect to the server if it detects that the connection is broken.

@gamedev8 I tested this and it seems that the WebSocket client can still be pinged by the server even while stepping through your code in dev tools. Could you test this yourself and confirm?

@gamedev8
Copy link

gamedev8 commented Feb 7, 2020

@Loonride I tested it a few days ago and produced the issue, but it is possible that I did not set up properly. I will try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants