Skip to content

WebSocketClient, fixed starvation condition#738

Open
bridgedragon wants to merge 1 commit intoNethereum:masterfrom
swapper-org:master
Open

WebSocketClient, fixed starvation condition#738
bridgedragon wants to merge 1 commit intoNethereum:masterfrom
swapper-org:master

Conversation

@bridgedragon
Copy link
Copy Markdown

@bridgedragon bridgedragon commented Nov 20, 2021

If method "HandleIncomingMessagesAsync()" is called before the websocket client is connected, the while() loop will get stuck in starvation condition, making continuous comparison without any CPU pause. This won't allow "_clientWebSocket" to connect, because CPU is stuck in that method, not allowing any other tasks to continue.

I propose initializing the listener when "_clientWebSocket" is already connected. May I propose other solutions, with an AutoResetEvent variable setted when a request is added to "_requests", if you do not like to initialize the listener at this point.

Starvation condition is tested and triggered in Ubuntu 21.04 (and I suppose it is happening in another OS). When "StreamingWebSocketClient" is instantiated in any project, the program will be stuck by 100% CPU usage.

@juanfranblanco
Copy link
Copy Markdown
Member

As per other threads.. (and new people coming over) I did not see any mayor improvements but keeping it open, in case it helps others.

@Nethereum Nethereum locked and limited conversation to collaborators Oct 28, 2025
@Nethereum Nethereum deleted a comment from buqunzzz Oct 28, 2025
@Nethereum Nethereum unlocked this conversation Oct 28, 2025
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.

2 participants