-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrupted frame content + workaround #58
Comments
Ha I think this is because I mask the frame in-place before sending it to the client, as the websocket protocol requires. The right thing to do is indeed probably to make a copy of the content and not mask-in-place to avoid the issue you encountered. So option 2 :) |
I think for performance reasons the current behaviour should be kept or be enabled with a parameter. That's also how high-performance WebSocket libraries like uws do it. |
Since I upgraded to 2.7 today, I have a (maybe) related problem when accessing the content of received frames. I have no simple repro case but here is what I do: let handler conn_client =
let req = Websocket_lwt.Connected_client.http_request conn_client in
let recv () = Websocket_lwt.Connected_client.recv conn_client in
let send = Websocket_lwt.Connected_client.send conn_client in
let stream = Websocket_lwt.mk_frame_stream recv in
<handle stream of frames>
in
let (waiter, stopper) = Lwt.wait () in
let thread = Websocket_lwt.establish_standard_server
~stop: waiter ~ctx ~mode:server handler
in
Lwt.return { stopper ; thread } When handling the stream of frames, I ignore the frames with |
In that case, perhaps there should be two interfaces, one that uses |
The
content
field of a Frame gets corrupted with random data after sending the frame. The workaround is to discard the content string after use or to make a copy before sending. I haven't looked into the problem close enough to determine the source of the problem but here's how to reproduce it:The output is something like:
while it should be:
The workaround works well enough for our purposes, but it would be good to do something to save time to others. Some suggestions, from easier to better:
Frame.create
explaining that the frame can't be reused (and perhaps set a flag preventing its reuse)content
field (slightly wasteful but imposes no burden on the user)OCaml version: 4.02.3 on amd64
The text was updated successfully, but these errors were encountered: