[Libwebsockets] lws_get_child()

Joel Winarske joel.winarske at gmail.com
Thu Mar 30 02:15:18 CEST 2017


I'm not sure.  Here's my log:

lwsws[11963]: http: LWS_CALLBACK_HTTP: REST
lwsws[11963]: http: LWS_CALLBACK_HTTP_BODY: REST
lwsws[11963]: http: (0x198ec80) LWS_CALLBACK_HTTP_BODY_COMPLETION
lwsws[11963]: http: LWS_CALLBACK_HTTP_BODY_COMPLETION: REST
lwsws[11963]: Send Request:
lwsws[11963]: url:
http://www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png
lwsws[11963]: method: HEAD
lwsws[11963]: using http mode (non-ws)
lwsws[11963]: HEAD mode
lwsws[11963]: http client: connecting
lwsws[11963]: lws_client_connect_2: 0x19a7f60: address www.google.com
lwsws[11963]: http: 29: (0x19a7f60) v=0x18c4810, ctx=0x186cc00
lwsws[11963]: lws_client_connect_via_info sucessful
lwsws[11963]: Exit - handle_rest_send()
lwsws[11963]: lws_client_connect_2: 0x19a7f60: address www.google.com
lwsws[11963]: http: (0x19a7f60)
LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, uri=(nil), spa=0x1918170
lwsws[11963]: lws_client_interpret_server_handshake: incoming content
length 3170
lwsws[11963]: http: (0x19a7f60) LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH:
v=0x18c4810, ctx=0x186cc00
    http/1.1  200 OK
    cache-control: private, max-age=31536000
    content-length: 3170
    content-type: image/png
    date: Thu, 30 Mar 2017 00:11:54 GMT
    accept-ranges: bytes
    expires: Thu, 30 Mar 2017 00:11:54 GMT
    last-modified: Thu, 08 Dec 2016 01:00:57 GMT
    server: sffe
lwsws[11963]: http: (0x19a7f60) LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: 200
lwsws[11963]: **** 0x198ec80 queued header for writing, buff=0x199b6a0
len=301 [1]
lwsws[11963]: **** CLIENT RELAY SET
    write_list_append - ((nil)) id=1, len=301, sum=0, header=1,
buff=0x199b6a0, chunk_end=0, next=(nil)
    client_content_length=0
lwsws[11963]: lws_client_interpret_server_handshake: client connection up
lwsws[11963]: http: (0x198ec80) LWS_CALLBACK_HTTP_WRITEABLE: v=0x18c4810,
ctx=0x186cc00, list_head=0x19611c0, next=(nil)
lwsws[11963]: [1] wrote 301 bytes (0x198ec80) 8
    client_content_length=0
lwsws[11963]: **** CLIENT RELAY CLEARED
lwsws[11963]: http: (0x198ec80) http_transaction_completed
lwsws[11963]: 172.16.19.75 - - [29/Mar/2017:17:11:54 -0700] "POST
/rest/send http/1.1" 200 301 Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/55.0.2883.87
Chrome/55.0.2883.87 Safari/537.36
lwsws[11963]: http: (0x198ec80) LWS_CALLBACK_HTTP_DROP_PROTOCOL:
v=0x18c4810, ctx=0x186cc00
lwsws[11963]: http: 49: (0x198ec80) v=0x18c4810, ctx=0x186cc00
lwsws[11963]: http: 51: (0x198ec80) v=0x18c4810, ctx=0x186cc00
lwsws[11963]: http: LWS_CALLBACK_HTTP: REST
lwsws[11963]: http: LWS_CALLBACK_HTTP_BODY: REST
lwsws[11963]: http: (0x198ec80) LWS_CALLBACK_HTTP_BODY_COMPLETION
lwsws[11963]: http: LWS_CALLBACK_HTTP_BODY_COMPLETION: REST
lwsws[11963]: Send Request:
lwsws[11963]: url: https://uas-api.inrix.com/...
lwsws[11963]: method: POST
lwsws[11963]: mimetype: application/json
lwsws[11963]: payload: ...
lwsws[11963]:  Using SSL
lwsws[11963]:  Selfsigned certs allowed
lwsws[11963]:  Skipping peer cert hostname check
lwsws[11963]: using https mode (non-ws)
lwsws[11963]: POST mode
lwsws[11963]: http client: connecting
lwsws[11963]: lws_client_connect_2: 0x19915d0: address uas-api.inrix.com
lwsws[11963]: http: 29: (0x19915d0) v=0x18c4810, ctx=0x186cc00
lwsws[11963]: lws_client_connect_via_info sucessful
lwsws[11963]: Exit - handle_rest_send()
lwsws[11963]: lws_client_connect_2: 0x19915d0: address uas-api.inrix.com
lwsws[11963]: lws_ssl_client_connect2: SSL_connect says -1
lwsws[11963]: lws_ssl_client_connect2: SSL_connect says -1
lwsws[11963]: lws_ssl_client_connect2: SSL_connect says 1
lwsws[11963]: get_verify says 0
lwsws[11963]: http: (0x19915d0)
LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, uri=(nil), spa=0x1951d90
lwsws[11963]: http: (0x19915d0) LWS_CALLBACK_CLIENT_HTTP_WRITEABLE
lwsws[11963]: lws_spa_destroy: destroy spa 0x1951d90
lwsws[11963]: lws_client_interpret_server_handshake: incoming content
length 1244
lwsws[11963]: http: (0x19915d0) LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH:
v=0x18c4810, ctx=0x186cc00
    connection: keep-alive
    http/1.1  200 OK
    pragma: no-cache
    cache-control: no-cache
    content-length: 1244
    content-type: application/json; charset=utf-8
    date: Thu, 30 Mar 2017 00:11:40 GMT
    expires: -1
    server: Microsoft-IIS/8.5
lwsws[11963]: http: (0x19915d0) LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: 200
lwsws[11963]: **** 0x198ec80 queued header for writing, buff=0x199b6a0
len=234 [1]
lwsws[11963]: **** CLIENT RELAY SET
    write_list_append - ((nil)) id=1, len=234, sum=0, header=1,
buff=0x199b6a0, chunk_end=0, next=(nil)
    client_content_length=1244
lwsws[11963]: lws_client_interpret_server_handshake: client connection up
lwsws[11963]: **** 0x198ec80 queued buffer for writing, buff=0x199beb0,
sum=1244, total=1244 [2]
    write_list_append - ((nil)) id=1, len=234, sum=0, header=1,
buff=0x199b6a0, chunk_end=0, next=0x19b6540
    write_list_append - ((nil)) id=2, len=1244, sum=1244, header=0,
buff=0x199beb0, chunk_end=0, next=(nil)
    client_content_length=1244
lwsws[11963]: http: (0x19915d0) LWS_CALLBACK_COMPLETED_CLIENT_HTTP
lwsws[11963]: http: (0x19915d0) http_transaction_completed
lwsws[11963]: http: (0x19915d0) LWS_CALLBACK_HTTP_DROP_PROTOCOL:
v=0x18c4810, ctx=0x186cc00
lwsws[11963]: lws_http_client_read: transaction completed says -1
lwsws[11963]: LWS_CALLBACK_RECEIVE_CLIENT_HTTP closed it
lwsws[11963]: lws_remove_child_from_any_parent: failed to detach from parent
lwsws[11963]: http: (0x198ec80) LWS_CALLBACK_HTTP_WRITEABLE: v=0x18c4810,
ctx=0x186cc00, list_head=0x195b490, next=0x19b6540
lwsws[11963]: [1] wrote 234 bytes (0x198ec80) 8
    post write - ((nil)) id=2, len=1244, sum=1244, header=0,
buff=0x199beb0, chunk_end=0, next=(nil)
    client_content_length=1244
lwsws[11963]: http: (0x198ec80) LWS_CALLBACK_HTTP_WRITEABLE: v=0x18c4810,
ctx=0x186cc00, list_head=0x19b6540, next=(nil)
lwsws[11963]: [2] wrote 1244 bytes (0x198ec80) 3
    client_content_length=0
lwsws[11963]: **** CLIENT RELAY CLEARED


On Wed, Mar 29, 2017 at 4:59 PM, Andy Green <andy at warmcat.com> wrote:

>
>
> On 03/30/2017 07:53 AM, Joel Winarske wrote:
>
>> Hi Andy I'm seeing something odd with connections.
>>
>> In my http client setup code I have:
>>
>> if (lws_get_child(wsi))
>> return 1;
>>
>> My first incoming client POST works, the second fails as lws_get_child()
>> returns non-zero.
>>
>> What will cause lws_get_child() to return non-zero, and how do I avoid it?
>>
>
> Is the original child wsi actually getting deleted after the end of the
> first POST?
>
> If it is, notice that not only should the parent point to the child, but
> child wsi must point to their parent (in child_wsi->parent). That will
> trigger removal from the parent when the child closes (in
> lws_remove_child_from_any_parent())
>
> lws_adopt_descriptor_vhost(..., parent) takes care about that though...
>
> -Andy
>
>
>> If I ignore this call, it will carry on, http client connects, data is
>> exchanged, then it get:
>>
>>     lwsws[11963]: LWS_CALLBACK_RECEIVE_CLIENT_HTTP closed it
>>     lwsws[11963]: lws_remove_child_from_any_parent: failed to detach
>> from parent
>>
>>
>> Joel
>>
>>
>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> https://libwebsockets.org/mailman/listinfo/libwebsockets
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20170329/7c3ba426/attachment-0002.html>


More information about the Libwebsockets mailing list