dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.47k stars 4.77k forks source link

Change/Remove ClientWebSocket ping packet body #110158

Open zxcvqwerasdf opened 1 week ago

zxcvqwerasdf commented 1 week ago

As i know, there is no way send ping's with ClientWebSocket directly, only by using

_webSocket.Options.KeepAliveInterval

But it's sends integer in body Image Can you add feature to do not send ping packet body? Only ping opcode? Thank you.

MihaZupan commented 1 week ago

Why do you care whether the extra bytes are sent / what's the motivation to avoid it?

zxcvqwerasdf commented 1 week ago

Why do you care whether the extra bytes are sent / what's the motivation to avoid it?

I am using custom ping/pong on the server and i need custom data in ping message

CarnaViire commented 6 days ago

custom ping/pong on the server

// TL;DR: Custom Ping/Pong on the server could only apply to server's Pings, it is fully independent from what the client sends in the client's Pings.

@zxcvqwerasdf Ping/Pongs initiated from the client side and from the server side are two separate things.

By RFC, the receiver of a Ping frame MUST echo back the data in the Pong response:

   A Pong frame sent in response to a Ping frame must have identical
   "Application data" as found in the message body of the Ping frame
   being replied to.

What that means:

1) If Ping/Pongs are initiated from the client side:

2) If Ping/Pongs are initiated from the server side:

dotnet-policy-service[bot] commented 6 days ago

This issue has been marked needs-author-action and may be missing some important information.

MihaZupan commented 6 days ago

custom data in ping message

What sort of information would you want to transmit? What's the motivation behind using pings instead of regular messages? Note that the size of ping data is very limited whereas regular messages can be arbitrarily large.