Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

High CPU usage when message size is exceeded #30

Open
@yahya99223

Description

I have created a websocket using Owin.Websocket.WebSocketConnection to receive messages from my Frontend.

public class MyWebScoket : WebSocketConnection
{
   protected MyWebScoket(int maxMessageSize = 65536) : base(maxMessageSize)
   {
      //logic
   }
   public override void OnClose(WebSocketCloseStatus? closeStatus, string closeStatusDescription)
   {
       //logic
   }
   public override Task OnMessageReceived(ArraySegment<byte> message, WebSocketMessageType type)
   {
       //logic
   }
   public override void OnOpen()
   {
       //logic
   }
   public override void OnReceiveError(Exception error)
   {
       //logic
   }
}

When the message size is below the set message size, CPU usage of API is normal and everything is functioning as it should, however when the message size exceeds the limit, CPU usage of API increases dramatically, causing my machine to stop responding even to mouse clicks.

This seems strange, as the message sending rate is always the same.

What is the reason of such behavior?

I added breakpoints inside all overridden methods, but none of them is reached, I thought if the message limit size is exceeded the execution should go to OnReceiveError.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions