flow control over websockets #5098
Replies: 1 comment 3 replies
-
@marvinthepa Ah sorry, I admit that the websocket flow control part is a bit vaguely phrased, as it does not show a real implementation. Meant is the following:
The notice
is just a friendly reminder, that an implementation must take care to measure the same entities on both ends, thus all messages accounted on one end also have to be accounted on the other side the same way, even with the same type (e.g. counting raw bytes on one side vs. counting string chars on the other side is a bad idea, encoding differences would stack up). Your example looks good to me, and if it works for you, then you are all set. Theoretically sending the number of transmitted bytes in the ACK message is not needed, if you define a fixed BYTE_LIMIT value on both sides. Ofc sending it along can give a few advantages, e.g. if you have a faulty connection and want to implement more sophisticated integrity checks. (But thats hardly an issue anymore with HTML/websockets).
The part "Ideas for a better mechanism" mostly shows ideas, how to overcome some perf issues from callback-based impls in nodejs, esp. around kernel ctx switches and general callback pressure (function call overhead). Idk, if thats relevant for you, since you use JSON as transport format, which should show a much worse perf impact here. And last but not least - if you have a better / more comprehensible example, feel free to open a PR for it here https://github.com/jerch/xtermjs.org Sidenote - if you need high throughput over websocket, use raw bytes instead, and do a little bit of prebuffering of PTY output before wrapping data into websocket packages. |
Beta Was this translation helpful? Give feedback.
-
I have two items for discussion about https://xtermjs.org/docs/guides/flowcontrol/, more precisely the "Flow control over websockets" section
ackCondition
,condition
, andstopCondition
are supposed to be exactly. Could this be clarified in any way?I tried to derive them from the examples in the other sections, and ended with an implementation similar to this:
with
BYTE_LIMIT
the same on both sides. It seems to work, but I have no idea if "the client side and condition / stopCondition on the server side agree about the things to measure", or if "the flow control will block the stream sooner or later"..I also tried to figure out a way it can be combined with the approach from the "Ideas for a better mechanism", but wasn't quite sure if this is even possible..
Beta Was this translation helpful? Give feedback.
All reactions