[Libwebsockets] Socket close during some HTTP gets

Michael Behrns-Miller moodboom at gmail.com
Wed Jan 18 23:25:11 CET 2017


Hello!

I am working on interweaving an http get with a persistent wss client
connection back to a server.  I am using one context and one protocol.
lws always seems to go into "chunked' mode for the http get.  Some
sites work, and others drop the socket connection before finishing the
http get.

To get it working, there is a lot to get right, and i am probably
getting some part of it wrong.

My strategy was to use a standard wss client connection (that went
fine).  Then for the http get, I create a second
lws_client_connect_info and wsi for it, and attach it to the context
with lws_client_connect_via_info().

All my testing with local pages, big and small, seemed to work fine.
Other tests (in this case a simple google query) gave this -d15 level
debugging and failed to COMPLETE:

[2017/01/18 16:42:09:3646] WARN: LWS_CALLBACK_RECEIVE_CLIENT_HTTP
[2017/01/18 16:42:09:3646] WARN:
LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ: received 365 bytes
[2017/01/18 16:42:09:3646] WARN: HTTP_READ of 365 bytes begins:
on(a){try{var b=docu
[2017/01/18 16:42:09:3646] WARN: HTTP_READ of 365 bytes ends :
/(^|\\?|&)ei=/.test(
[2017/01/18 16:42:09:3646] WARN: LWS_CALLBACK_RECEIVE_CLIENT_HTTP
[2017/01/18 16:42:09:3646] INFO: lws_close_free_wsi: real
just_kill_connection: 0x5555557dfe90 (sockfd 7)
[2017/01/18 16:42:09:3646] INFO: remove_wsi_socket_from_fds: removing
same prot wsi 0x5555557dfe90
[2017/01/18 16:42:09:3646] INFO: remove_wsi_socket_from_fds:
wsi=0x5555557dfe90, sock=7, fds pos=2, end guy pos=3, endfd=0
[2017/01/18 16:42:09:3647] INFO: lws_header_table_detach: wsi
0x5555557dfe90: ah (nil) (tsi=0, count = 0)

Some of the http gets do not log any errors, but never finish.  In
debugging the code, I usually find that the call is perceived as
chunked for some reason, and I guess the final chunked marker is never
hit.

Sorry Andy, that's a small bit of the picture I know.  Any advice?
Even if it is just something to try.  Appreciate it.

Michael


More information about the Libwebsockets mailing list