-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP/1.1 not persistant connection #3176
Comments
You have to indicate in the client info that you want http1.1 or h2 chained transactions. And then if the original connection is still hanging around idle (on both sides) it will try to reuse it. See struct lws_client_connect_info https://github.com/warmcat/libwebsockets/blob/main/include/libwebsockets/lws-client.h#L64-L71 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, currently I am developing an application which uses HTTP 1.1 GET requests (https) to gather data from server very frequently.
Now I have a problem with the performance of my application - after a successful transaction the connection seems to be closed and on the next request the whole connection is built up from scratch - causing loss of time (around 200ms to establish connection again).
As far as I understand, the connections in HTTP/1.1 should be persisitant (connection timeout several seconds).
But in my case the connection closes, I get callbacks in this order (on repeated request, just few milliseconds after previous connection):
calling -> lws_client_connect_via_info()
LWS_CALLBACK_CLIENT_HTTP_BIND_PROTOCOL
LWS_CALLBACK_CONNECTING
LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED
LWS_CALLBACK_WSI_CREATE
LWS_CALLBACK_OPENSSL_PERFORM_SERVER_CERT_VERIFICATION (comes after 200ms)
LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER
LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH
LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP
LWS_CALLBACK_RECEIVE_CLIENT_HTTP
LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ
LWS_CALLBACK_COMPLETED_CLIENT_HTTP
LWS_CALLBACK_RECEIVE_CLIENT_HTTP
LWS_CALLBACK_CLIENT_HTTP_DROP_PROTOCOL
LWS_CALLBACK_CLOSED_CLIENT_HTTP
LWS_CALLBACK_WSI_DESTROY
However I see a header during header exchange:
"Connection: close"
2024-07-03T08:08:08.683+02:00 P: WSI_TOKEN_NAME_PART 'C' 0x43 (role=0x10000000) wsi->lextable_pos=0
2024-07-03T08:08:08.683+02:00 P: WSI_TOKEN_NAME_PART 'o' 0x6F (role=0x10000000) wsi->lextable_pos=102
2024-07-03T08:08:08.683+02:00 P: WSI_TOKEN_NAME_PART 'n' 0x6E (role=0x10000000) wsi->lextable_pos=109
2024-07-03T08:08:08.683+02:00 P: WSI_TOKEN_NAME_PART 'n' 0x6E (role=0x10000000) wsi->lextable_pos=116
2024-07-03T08:08:08.683+02:00 P: WSI_TOKEN_NAME_PART 'e' 0x65 (role=0x10000000) wsi->lextable_pos=123
2024-07-03T08:08:08.683+02:00 P: WSI_TOKEN_NAME_PART 'c' 0x63 (role=0x10000000) wsi->lextable_pos=124
2024-07-03T08:08:08.683+02:00 P: WSI_TOKEN_NAME_PART 't' 0x74 (role=0x10000000) wsi->lextable_pos=125
2024-07-03T08:08:08.684+02:00 P: WSI_TOKEN_NAME_PART 'i' 0x69 (role=0x10000000) wsi->lextable_pos=126
2024-07-03T08:08:08.684+02:00 P: WSI_TOKEN_NAME_PART 'o' 0x6F (role=0x10000000) wsi->lextable_pos=133
2024-07-03T08:08:08.684+02:00 P: WSI_TOKEN_NAME_PART 'n' 0x6E (role=0x10000000) wsi->lextable_pos=134
2024-07-03T08:08:08.684+02:00 P: WSI_TOKEN_NAME_PART ':' 0x3A (role=0x10000000) wsi->lextable_pos=135
2024-07-03T08:08:08.684+02:00 P: known hdr 4
2024-07-03T08:08:08.684+02:00 P: WSI_TOK_(4) ' '
2024-07-03T08:08:08.684+02:00 P: WSI_TOK_(4) 'c'
2024-07-03T08:08:08.684+02:00 P: WSI_TOK_(4) 'l'
2024-07-03T08:08:08.684+02:00 P: WSI_TOK_(4) 'o'
2024-07-03T08:08:08.684+02:00 P: WSI_TOK_(4) 's'
2024-07-03T08:08:08.684+02:00 P: WSI_TOK_(4) 'e'
2024-07-03T08:08:08.684+02:00 P: WSI_TOK_(4) ''
Do you have any suggestion why my connection is closing every time? Am I doing something wrong?
Thank you.
The text was updated successfully, but these errors were encountered: