Open xozzslip opened 2 months ago
I use the 1011 code instead of 1006 for non-zero exit codes. Binary is here if anyone needs it: https://github.com/xozzslip/ttyd/releases/tag/1.7.7
diff --git a/src/protocol.c b/src/protocol.c
index 53e65d4..d9d0865 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -86,7 +86,7 @@ static void process_read_cb(pty_process *process, pty_buf_t *buf, bool eof) {
}
if (eof && !process_running(process))
- ctx->pss->lws_close_status = process->exit_code == 0 ? 1000 : 1006;
+ ctx->pss->lws_close_status = process->exit_code == 0 ? 1000 : 1011;
else
ctx->pss->pty_buf = buf;
lws_callback_on_writable(ctx->pss->wsi);
@@ -101,7 +101,7 @@ static void process_exit_cb(pty_process *process) {
lwsl_notice("process exited with code %d, pid: %d\n", process->exit_code, process->pid);
ctx->pss->process = NULL;
- ctx->pss->lws_close_status = process->exit_code == 0 ? 1000 : 1006;
+ ctx->pss->lws_close_status = process->exit_code == 0 ? 1000 : 1011;
lws_callback_on_writable(ctx->pss->wsi);
When running ttyd, if a command exits with a code other than 0, ttyd sends a WebSocket control code 1006. However, according to the WebSocket specification, code 1006 is a reserved value and should not be sent by the server explicitly. This behavior causes issues when running ttyd behind a proxy that uses the Gorilla WebSocket library, as it triggers an error when the proxy detects that the server has sent a 1006 code.