HTTPS client is not reading all the data from socket #63030
-
I am playing with While the plain HTTP client on ipv4 works fine, I have some issues with HTTPS. When downloading a file over a HTTPS/TLSv1.2 connection, the last TLS packet is not processed and pushed into user callback. ret = zsock_poll(fds, nfds, remaining_time);
if (ret == 0) {
LOG_DBG("Timeout");
goto finalize_data;
} else if (ret < 0) {
goto error;
}
if (fds[0].revents & (ZSOCK_POLLERR | ZSOCK_POLLNVAL)) {
goto error;
} else if (fds[0].revents & ZSOCK_POLLHUP) {
/* Connection closed */
LOG_DBG("Connection closed");
goto finalize_data;
} else if (fds[0].revents & ZSOCK_POLLIN) { There is a check if the socket is in a POLLHUP state, and if it is, the connection is considered closed, and no more data is being read from the socket. According to the POSIX manual there could be data to read:
More so, if I comment out this check, I can successfully read the whole file without any issues. So, does this code work correctly? Do I have some misconfiguration somewhere? Or is it a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
-
Hi @d-makarenko, it seems you're right, we should still call |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I've also encountered the same issue as @d-makarenko. Could you please provide an update on the progress? Has the pull request been created? |
Beta Was this translation helpful? Give feedback.
Hi @d-makarenko, it seems you're right, we should still call
recv()
after gettingZSOCK_POLLHUP
, so it looks like a bug on the HTTP client side. On second thought, I think we may even skip theZSOCK_POLLHUP
at all, as it should always be accompanied withZSOCK_POLLIN
, and leave it up torecv()
to detect connection close. Would you be willing to send a PR to fix that?