[Libwebsockets] Better way to send large http response

Chanson Shen shenchsh94 at gmail.com
Wed Sep 19 01:17:01 CEST 2018

Hi all,

I'm running libwebsocket v3.0-stable and trying to implement RESTful API

When the server tries to send large message(=45431 bytes) back to client.
In `LWS_CALLBACK_HTTP_WRITEABLE`, `lws_write()` returns 45431, which means
it accepts all the data. And `lws_http_transaction_completed()` returns 1.
Then `return -1` is called to close the connection.

But it seems `LWS_CALLBACK_HTTP_WRITEABLE` will be invoked again with
`lws_send_pipe_choked()` returning 1. On client side, it only receives part
of the data. I was expecting all the data had been sent, and the connection
should be closed successfully.

I checked the document, and I am not sure if it is related to `truncated
writes` mentioned in this page:

Any idea on my issue and what's the best way to send large http response
message? Thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20180918/52321cf9/attachment.html>

More information about the Libwebsockets mailing list