Skip to content

Conversation

arter97
Copy link

@arter97 arter97 commented Oct 8, 2025

This PR tries to resolve excessive CPU usage and stale socket when a connection is made towards a SSL WebSocket with no proper handshaking.

Description

First commit throttles processHandshake() by 10ms to avoid busy looping and consuming an entire CPU core.
Second commit forcefully closes the socket if no handshake is done under 60s.

Related Issue

#896

Motivation and Context

I'm extremely surprised this isn't resolved yet.

I was debugging an issue on my app that sometimes hogs an entire CPU core up.
This was hard to hunt down as it's not consistent.

I finally narrowed it down to a rogue client trying to connect over to my SSL WebSocket server.
With no valid SSL handshake, it hogged up an entire CPU core indefinitely.

This would be an extremely frequent phenomenon unless the device is strictly limited to a controlled local network.

How Has This Been Tested?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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.

1 participant