[Libwebsockets] Use of libwebsockets_serve_http_file()

Andy Green andy at warmcat.com
Fri Oct 16 02:52:18 CEST 2015



On 15 October 2015 14:04:50 GMT+09:00, Mark Hessling <rexx.org at internode.on.net> wrote:
>I have built a Rexx API for lws and have been using it successfully for
>
>several months now.  I have recently come across a behavioural problem 
>with libwebsockets_serve_http_file(). I assume that the purpose of this
>
>function is to let lws serve the requested file back to the client and 
>that's all the server has to do, but I've found that this is not
>reliable.
>
>If I attempt to serve a largish (130k) file back to a client where the 
>connection is slow, the client times out waiting for the server to send
>
>the file.  In my particular circumstance I am serving the JQuery 
>Javascript package back to a client running on a mobile phone over a 
>cellular network.  If the connection is fast (client and server on same
>
>network) the file is served completely.
>I've easily replicated this problem on a local network by using
>Chrome's 
>throttling mechanism in its developer tools.
>
>Am I assuming the incorrect behaviour of
>libwebsockets_serve_http_file() 
>for large files over slow connections, or should it work?

Try setting

    libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);

Before starting sending the file.  If that solves it, pick a nonzero timeout (in seconds) that makes sense for you.

-Andy

>Thanks, Mark
>------------------------------------------------------------------------
>* Mark Hessling, mark at rexx.org http://www.rexx.org/
>* Author of THE, a Free XEDIT/KEDIT editor and, Rexx/SQL, Rexx/CURL,
>etc.
>* Maintainer of Regina Rexx interpreter and Rexx/Tk
>* Use Rexx? join the Rexx Language Association: http://www.rexxla.org/
>------------------------------------------------------------------------
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list