shell: taos shell websocket reconnect error
This commit is contained in:
parent
4ebdab3540
commit
d3a21816cc
|
@ -143,7 +143,7 @@ void shellCheckConnectMode() {
|
||||||
shell.args.port = 6041;
|
shell.args.port = 6041;
|
||||||
}
|
}
|
||||||
shell.args.dsn = taosMemoryCalloc(1, 1024);
|
shell.args.dsn = taosMemoryCalloc(1, 1024);
|
||||||
snprintf(shell.args.dsn, 1024, "ws://%s:%d/rest/ws",
|
snprintf(shell.args.dsn, 1024, "ws://%s:%d",
|
||||||
shell.args.host, shell.args.port);
|
shell.args.host, shell.args.port);
|
||||||
}
|
}
|
||||||
shell.args.cloud = false;
|
shell.args.cloud = false;
|
||||||
|
|
|
@ -206,16 +206,18 @@ void shellRunSingleCommandWebsocketImp(char *command) {
|
||||||
printMode = true; // When output to a file, the switch does not work.
|
printMode = true; // When output to a file, the switch does not work.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shell.stop_query = false;
|
||||||
|
WS_RES* res;
|
||||||
|
|
||||||
|
for (int reconnectNum = 0; reconnectNum < 2; reconnectNum++) {
|
||||||
if (!shell.ws_conn && shell_conn_ws_server(0)) {
|
if (!shell.ws_conn && shell_conn_ws_server(0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.stop_query = false;
|
|
||||||
st = taosGetTimestampUs();
|
st = taosGetTimestampUs();
|
||||||
|
|
||||||
WS_RES* res = ws_query_timeout(shell.ws_conn, command, shell.args.timeout);
|
res = ws_query_timeout(shell.ws_conn, command, shell.args.timeout);
|
||||||
int code = ws_errno(res);
|
int code = ws_errno(res);
|
||||||
if (code != 0) {
|
if (code != 0 && !shell.stop_query) {
|
||||||
et = taosGetTimestampUs();
|
et = taosGetTimestampUs();
|
||||||
fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6);
|
fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6);
|
||||||
if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) {
|
if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) {
|
||||||
|
@ -225,8 +227,11 @@ void shellRunSingleCommandWebsocketImp(char *command) {
|
||||||
shell.ws_conn = NULL;
|
shell.ws_conn = NULL;
|
||||||
}
|
}
|
||||||
ws_free_result(res);
|
ws_free_result(res);
|
||||||
|
if (reconnectNum == 0) continue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
double execute_time = ws_take_timing(res)/1E6;
|
double execute_time = ws_take_timing(res)/1E6;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue