Replies: 2 comments 1 reply
-
I have previously written code for forwarding data between two NetworkStreams, and this issue will not occur. Is there anything special about websocket? async Task ForwardData(NetworkStream source, NetworkStream destination, CancellationToken? token = null)
{
token ??= CancellationToken.None;
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = await source.ReadAsync(buffer, token.Value)) > 0)
{
await destination.WriteAsync(
new ReadOnlyMemory<byte>(buffer, 0, bytesRead),
token.Value
);
}
}
NetworkStream src;
NetworkStream dist;
var forwardToRemote = ForwardData(src, dist);
var forwardToClient = ForwardData(dist, src)
await Task.WhenAny(forwardToRemote, forwardToClient); |
Beta Was this translation helpful? Give feedback.
0 replies
-
It's legal and should work if you have concurrent reads and writes with the websocket. Can you share a repro? Where does podWebSocket come from? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I am writing a K8s web terminal that receives ws requests from the web end and then proxies them to K8s through a wsclient. If I don't use a channel in memory to relay requests from the web, a deadlock will occur. Why is this phenomenon happening?
My architecture model is as follows:

And my pseudo code is as follows:
Invalid code:
Valid code:
Beta Was this translation helpful? Give feedback.
All reactions