[Libwebsockets] What is the proper way to keep stream connection?

Kun Zhao kunzhao77 at gmail.com
Sun Apr 28 02:31:31 CEST 2019


Hi Andy,

I have a HTTP client which receives data from a server. The connection is
kept alive and the server sends data to the client periodically. The client
receives data for a while then closed the connection. After some debugging,
I found that the problem is here:
https://github.com/warmcat/libwebsockets/blob/2d2c0f0f9241fa449018baececdab83289b1e0f9/lib/core-net/service.c#L708

the ah->assigned never updates and the session eventually timed out then
and the client closed the connection.

What is the proper way to update the ah->assigned time stamp to keep the
connection open?

Following is the response header from the server.

HTTP/1.1 200 OK
Server: openresty/1.9.15.1
Date: Sat, 27 Apr 2019 21:11:14 GMT
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Connection: close
Access-Control-Allow-Headers: Authorization, Content-Type,
Accept-Datetime-Format, OANDA-Agent, ETag
Access-Control-Allow-Methods: PUT, PATCH, POST, GET, OPTIONS, DELETE
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, RequestID
RequestID: 799161546957200243

Following is the logs:
[2019/04/27 19:05:01:8002] NOTICE: ah excessive hold: wsi 00000000122CFC40
  peer address: 198.105.26.108
  ah pos 258
[2019/04/27 19:05:01:8032] NOTICE:    connection: = close
[2019/04/27 19:05:01:8042] NOTICE:    http/1.1  = 200 OK
[2019/04/27 19:05:01:8052] NOTICE:    content-type: =
application/octet-stream
[2019/04/27 19:05:01:8072] NOTICE:    date: = Sat, 27 Apr 2019 23:56:03 GMT
[2019/04/27 19:05:01:8092] NOTICE:    access-control-allow-origin: = *
[2019/04/27 19:05:01:8102] NOTICE:    server: = openresty/1.9.15.1
[2019/04/27 19:05:01:8122] NOTICE:    transfer-encoding: = chunked
[2019/04/27 19:05:01:8132] INFO: __lws_header_table_detach: wsi
00000000122CFC40: ah 000000001230F9C0 (tsi=0, count = 1)
[2019/04/27 19:05:01:8152] DEBUG: __lws_header_table_detach: wsi
00000000122CFC40: ah held 544s, role/state 0x10000000 0x117,
[2019/04/27 19:05:01:8182] INFO: __lws_header_table_detach: nobody usable
waiting
[2019/04/27 19:05:01:8202] INFO: _lws_destroy_ah: freed ah 000000001230F9C0
: pool length 0
[2019/04/27 19:05:01:8222] INFO: __lws_header_table_detach: wsi
00000000122CFC40: ah 000000001230F9C0 (tsi=0, count = 0)
[2019/04/27 19:05:01:8242] INFO: __lws_close_free_wsi: 00000000122CFC40:
caller: excessive ah
[2019/04/27 19:05:01:8262] DEBUG: __lws_close_free_wsi: real
just_kill_connection: 00000000122CFC40 (sockfd 260)
[2019/04/27 19:05:01:8282] DEBUG: __remove_wsi_socket_from_fds:
wsi=00000000122CFC40, skt=260, fds pos=0, end guy pos=1, endfd=0
[2019/04/27 19:05:01:8312] DEBUG: lwsi_set_state(00000000122CFC40,
0x1000001e)

Thanks,
Kun Zhao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20190427/53024b1c/attachment.htm>


More information about the Libwebsockets mailing list