From 269f135812dc002f85a2e14cf80042c726299bd8 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 22 Aug 2023 00:20:02 +0200 Subject: [PATCH] Fix Errno::ECONNRESET error for Tubesock * We must not close the socket manually (with `client_socket.close`), as this would close it twice. Compare: https://github.com/ngauthier/tubesock/blob/2c83794b85e86164f40a244061c60563a726c668/lib/tubesock.rb#L92 * When the socket is closed twice, nginx registers a `Connection reset by peer` error: `recv() failed (104: Connection reset by peer) while proxying upgraded connection` * Tubesock automatically closes the socket when the `hijack` block ends and otherwise ignores `Errno::ECONNRESET`: https://github.com/ngauthier/tubesock/blob/2c83794b85e86164f40a244061c60563a726c668/lib/tubesock.rb#L161-L162 --- app/controllers/submissions_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 386a351d..bc2ca034 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -313,7 +313,9 @@ class SubmissionsController < ApplicationController # We don't want to store this (arbitrary) exit command and redirect it ourselves client_socket.send_data JSON.dump({cmd: :exit}) client_socket.send_data nil, :close - client_socket.close + # We must not close the socket manually (with `client_socket.close`), as this would close it twice. + # When the socket is closed twice, nginx registers a `Connection reset by peer` error. + # Tubesock automatically closes the socket when the `hijack` block ends and otherwise ignores `Errno::ECONNRESET`. end def create_remote_evaluation_mapping