From b1e6c0a64c006b00c9b2b07e1b8ee96de2211f25 Mon Sep 17 00:00:00 2001 From: Sandmann <31391404+sandman21vs@users.noreply.github.com> Date: Wed, 24 Jun 2026 08:13:45 +0200 Subject: [PATCH] fix(CrealityPrint): avoid false 'End of file' error when K1 closes the WS after start (#14344) K1C: corrige erro 'End of file' ao enviar impressao (start_print) A K1-family fecha o WebSocket 9999 assim que aceita o comando de iniciar impressao. O start_print fazia um ws.read() bloqueante logo apos o write, que estourava 'End of file [asio.misc:2]' e era reportado como erro -- embora a impressao ja tivesse iniciado (o comando e entregue no write). Torna o read e o close best-effort (overloads com error_code), eliminando o falso erro. Mesmo padrao ja usado em feed_filament; cobre os caminhos single-color e multicor. --- src/slic3r/Utils/CrealityPrint.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/slic3r/Utils/CrealityPrint.cpp b/src/slic3r/Utils/CrealityPrint.cpp index 99f62a3824..772e1da80e 100644 --- a/src/slic3r/Utils/CrealityPrint.cpp +++ b/src/slic3r/Utils/CrealityPrint.cpp @@ -414,11 +414,19 @@ bool CrealityPrint::start_print(wxString &msg, const std::string &filename, cons }; ws.write(net::buffer(to_string(cmd))); + // K1-family firmware closes the WebSocket right after accepting the + // start command, so a blocking read here surfaces a benign + // "End of file [asio.misc:2]" even though the print already started + // (the command is delivered by write()). Read best-effort, ignore errors. beast::flat_buffer buffer; - ws.read(buffer); + beast::error_code read_ec; + ws.read(buffer, read_ec); } - ws.close(websocket::close_code::normal); + // Same reason: the printer may have already closed the connection. A close + // error here is not a failure — the start command was sent above. + beast::error_code close_ec; + ws.close(websocket::close_code::normal, close_ec); return true; } catch(std::exception const& e) { BOOST_LOG_TRIVIAL(error) << "CrealityPrint: Error starting print: " << e.what();