Improve TLS WebSocket and network failure diagnostics
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <webclient.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -131,12 +132,14 @@ static int webclient_read_line(struct webclient_session *session, char *buffer,
|
||||
FD_SET(session->socket, &read_fds);
|
||||
|
||||
ret = select(session->socket + 1, &read_fds, NULL, NULL, &t);
|
||||
int select_errno = ret < 0 ? errno : 0;
|
||||
|
||||
// printf("select ret: %d\r\n", ret);
|
||||
|
||||
if(ret <= 0)
|
||||
{
|
||||
printf("*** select timeout or error ***\r\n");
|
||||
printf("[HTTP-DIAG] stage=response_header reason=%s select_ret=%d errno_snapshot=%d timeout_ms=2000\r\n",
|
||||
ret == 0 ? "timeout" : "select_error", ret, select_errno);
|
||||
return -WEBCLIENT_ERROR;
|
||||
}
|
||||
|
||||
@@ -561,12 +564,14 @@ static int webclient_connect(struct webclient_session *session, const char *URI)
|
||||
FD_SET(socket_handle, &write_fds);
|
||||
|
||||
rc= select(socket_handle + 1, &read_fds, &write_fds, NULL, &t);
|
||||
int select_errno = rc < 0 ? errno : 0;
|
||||
|
||||
printf("select ret: %d\r\n", rc);
|
||||
|
||||
if(rc <= 0)
|
||||
{
|
||||
printf("*** select timeout or error ***\r\n");
|
||||
printf("[HTTP-DIAG] stage=tcp_connect reason=%s select_ret=%d errno_snapshot=%d timeout_ms=2000\r\n",
|
||||
rc == 0 ? "timeout" : "select_error", rc, select_errno);
|
||||
rc = -WEBCLIENT_CONNECT_FAILED;
|
||||
goto __exit;
|
||||
}
|
||||
@@ -1376,12 +1381,14 @@ int webclient_read(struct webclient_session *session, void *buffer, size_t lengt
|
||||
FD_SET(session->socket, &read_fds);
|
||||
|
||||
ret = select(session->socket + 1, &read_fds, NULL, NULL, &t);
|
||||
int select_errno = ret < 0 ? errno : 0;
|
||||
|
||||
// printf("select ret: %d\r\n", ret);
|
||||
|
||||
if(ret <= 0)
|
||||
{
|
||||
printf("*** select timeout or error ***\r\n");
|
||||
printf("[HTTP-DIAG] stage=response_body reason=%s select_ret=%d errno_snapshot=%d timeout_ms=2000\r\n",
|
||||
ret == 0 ? "timeout" : "select_error", ret, select_errno);
|
||||
return -WEBCLIENT_ERROR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user