[Libwebsockets] Use of libwebsockets_serve_http_file()

Andy Green andy at warmcat.com
Sun Nov 1 03:52:38 CET 2015



On 1 November 2015 10:36:54 GMT+08:00, Mark Hessling <mark at rexx.org> wrote:
>Hi Andy,
>
>Sorry I couldn't get back to you before now about this issue, but I've
>been overseas on holiday.
>
>I upgraded to v1.5 (from v1.3) and re-built my Rexx interface (with
>problems which I will document in another email).
>
>I am now calling libwebsocket_set_timeout( wsi, NO_PENDING_TIMEOUT, 0 )
>before each call to libwebsocket_serve_http_file() and the behaviour
>hasn't changed.  When running on Windows, my LWS server only sends 40k
>of the larger files when I have throttled the bandwidth.  So, nothing
>has changed by using the suggestion. 
>
>Note that this is only an issue on Windows; on Linux thee is no need
>for

Oh... I must have missed that in your email.  If Linux works well then it wouldn't be a bug like that.

>the call to libwebsocket_set_timeout() as the LWS server serves the
>complete files when throttling the bandwidth.
>
>As I've mentioned before this is a very easy problem to replicate by
>simply serving a file > 40k and using Chrome Developer Tools, throttle
>the bandwidth to GPRS speeds and the file serving will fail.

Yes... but all the windows stuff is contributed.

It seems though it's one of

 - the differences in lws-plat-xxx

 - something about windows' not very good WSA or other OS setting / difference

 - the client or some intermediary (pervy windows firewall) times him out

If he times out literally from lws point of view, especially if it happens at 5-6s, you can try changing AWAITING_TIMEOUT in private-libwebsockets.h, eg to 10s.

If the behaviour follows suit, you know clearly that behaviour is somehow related to lws timeout stuff in the library or user code.  If he stays the same, it's still ambiguous.

-Andy

>Cheers, Mark
>
>On 16/10/15 10:52, Andy Green wrote:
>>
>> 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