[Libwebsockets] Firefox client websocket error

Sumit Dubey sumitd2002 at yahoo.com
Sun Jul 5 07:46:28 CEST 2020


Andy, this seems to have worked. Thank you.
Sumit


Sent from Yahoo Mail for iPhone


On Thursday, July 2, 2020, 3:51 PM, Sumit Dubey <sumitd2002 at yahoo.com> wrote:




Sent from Yahoo Mail for iPhone


On Thursday, July 2, 2020, 3:14 PM, Andy Green <andy at warmcat.com> wrote:



On 7/2/20 10:36 AM, Sumit Dubey wrote:
> ...the way I am thinking of doing it is to break the message in the 
> writeable callback and reassemble it at the javascript side. Are you 
> referring to a better way?

Yes, ws natively understands message fragmentation.

https://tools.ietf.org/html/rfc6455#section-5.4

the browsers understand it too, and collect the pieces into the whole 
message before making the rx event in the JS.  So there is nothing to do 
on browser side if you send the ws fragments according to the standard. 
And of course lws supports this.

Since the rules are a bit confusing, there is a helper provided that 
converts flags for first part or last part into the right LWS_WRITE flags

https://libwebsockets.org/git/libwebsockets/tree/include/libwebsockets/lws-write.h?h=_temp#n221-246

if you use that you can just send your messages (of any size) using 
fragments fixed at a smaller size, like 2048 or whatever, feed the 
helper the first / last info about the fragment and use the helper's 
output for lws_write() flags.

If not the last part, or more messages queued, just call 
lws_callback_on_writeable() in the WRITEABLE callback to make sure you 
come back around again to do the next bit.

-Andy

> Sumit
> 
> On Thursday, 2 July 2020, 01:14:03 pm GMT+5:30, andy at warmcat.com 
> <andy at warmcat.com> wrote:
> 
> 
> 
> 
> On July 2, 2020 7:38:18 AM UTC, Sumit Dubey <sumitd2002 at yahoo.com 
> <mailto:sumitd2002 at yahoo.com>> wrote:
>  > Hi Andy,
>  >Can you please look
>  >at https://bugzilla.mozilla.org/show_bug.cgi?id=1619520, and give me
>  >any further insights on this?
>  >Wondering if sending 16500 bytes all at once is acceptable?
> 
> Rather than drag mozilla and me into solving your mystery why not just 
> break it down into smaller ws fragments?  That's something you can do by 
> yourself in your WRITEABLE callback, if it's happy then you can just 
> move on with your life.
> 
> 
> -Andy
> 
>  >Sumit
>  >On Friday, 28 February 2020, 02:09:12 pm GMT+5:30, Sumit Dubey
>  ><sumitd2002 at yahoo.com <mailto:sumitd2002 at yahoo.com>> wrote:
>  >
>  >  Hi Andy,
>  >I tried with protocols.tx_packet_size=1024 without any effect. I guess
>  >this is not an lws problem.Thank you for all your help.
>  >Sumit
>  >On Thursday, 27 February 2020, 07:03:54 pm GMT+5:30, Andy Green
>  ><andy at warmcat.com <mailto:andy at warmcat.com>> wrote:
>  >
>  >
>  >
>  >On February 27, 2020 6:59:04 AM GMT, Sumit Dubey <sumitd2002 at yahoo.com 
> <mailto:sumitd2002 at yahoo.com>>
>  >wrote:
>  >>libwebsockets::16::lws_ssl_capable_write failed:
>  >>error:00000005:lib(0):func(0):DH lib, errno 10053
>  >
>  >WSAECONNABORTED
>  >10053
>  >
>  >Software caused connection abort. An established connection was aborted
>  >by the software in your host computer, possibly due to a data
>  >transmission time-out or protocol error.
>  >
>  >https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
>  >
>  >AFAICT this is "browser hung up on us"... the logs don't show us
>  >deciding to hang up on the browser, the first we hear about it is an
>  >error writing the rest of the 16KB blob you sent all at once.
>  >
>  >-Andy
>  >
>  >>Sumit
>  >>On Wednesday, 26 February 2020, 06:05:06 pm GMT+5:30, Andy Green
>  >><andy at warmcat.com <mailto:andy at warmcat.com>> wrote:
>  >>
>  >>
>  >>
>  >>On 2/26/20 12:07 PM, Sumit Dubey wrote:
>  >>> I am on windows.
>  >>
>  >>Hm... what's the openssl version?
>  >>
>  >>Please try this one-line change (just do it by hand is OK)
>  >>
>  >>diff --git a/lib/tls/openssl/openssl-ssl.c
>  >>b/lib/tls/openssl/openssl-ssl.c
>  >>index 2a6ff9527..7feb57bcb 100644
>  >>--- a/lib/tls/openssl/openssl-ssl.c
>  >>+++ b/lib/tls/openssl/openssl-ssl.c
>  >>@@ -352,7 +352,7 @@ lws_ssl_capable_write(struct lws *wsi, unsigned
>  >>char
>  >>*buf, int len)
>  >>                }
>  >>        }
>  >>
>  >>-      lwsl_debug("%s failed: %s\n",__func__, ERR_error_string(m,
>  >>NULL));
>  >>+      lwsl_debug("%s failed: %s, errno %d\n",__func__,
>  >>ERR_error_string(m, NULL), LWS_ERRNO);
>  >>        lws_tls_err_describe_clear();
>  >>
>  >>        wsi->socket_is_permanently_unusable = 1;
>  >>
>  >>
>  >>Openssl err 5 is SSL_ERROR_SYSCALL... unfortunately, what that means
>  >>and
>  >>how to react is platform-dependent, the patch above should make it
>  >also
>  >>
>  >>dump errno, please check the logs for "lws_ssl_capable_write failed"
>  >>after it failed and let's see what it says.
>  >>
>  >>It could be just telling us the other side hung up, or it could be
>  >some
>  >>
>  >>errno status we can ignore rather than fail.
>  >>
>  >>-Andy
>  >>
>  >>> Firefox is 73.0.1.
>  >>>
>  >>> lws is master
>  >>> SHA512
>  >>>
>  >>0adc438720a2840fdc639c36fc35873133937ab43d4e4579306449d850f44669e2f650773a7cc551b1108bc155ec2fe3b20dd31d4d04bd870e29d7e34a9def1f
>  >>>
>  >>> (I guess this is the commit no.)
>  >>>
>  >>> Sumit
>  >>>
>  >>>
>  >>> On Wednesday, 26 February 2020, 05:25:55 pm GMT+5:30, Andy Green
>  >>> <andy at warmcat.com <mailto:andy at warmcat.com>> wrote:
>  >>>
>  >>>
>  >>>
>  >>>
>  >>> On 2/26/20 11:47 AM, Sumit Dubey wrote:
>  >>>  > Please find attached the lws logs around the time when the
>  >>websocket got
>  >>>  > disconnected.
>  >>>
>  >>> So you're using h2... you mentioned port 80 so I assumed not
>  >>>
>  >>>  >  >  >  > /The connection to wss://localhost:80/ was interrupted
>  >>while
>  >>>
>  >>> Firefox before 72 had a bug with its ws-over-h2 that I reported a
>  >>year
>  >>> ago on 65
>  >>>
>  >>> https://bugzilla.mozilla.org/show_bug.cgi?id=1528850
>  >>>
>  >>> they fixed it for 72.
>  >>>
>  >>> If that's not it, what version of lws is it?  Try it on master if
>  >not
>  >>> master.
>  >>>
>  >>> It's dying here
>  >>>
>  >>> libwebsockets::16::lws_ssl_capable_write failed:
>  >>> error:00000005:lib(0):func(0):DH lib
>  >>>
>  >>> that's a bit suspicious, is there something unusual about your
>  >>platform?
>  >>>
>  >>>
>  >>> -Andy
>  >>>
>  >>






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200705/5def16a3/attachment.htm>


More information about the Libwebsockets mailing list