Repository navigation
fix: connect the terminal at the ssh-terminal plugin path - #2
Merged
Merged
Conversation
Termix 2.9 moved the terminal into the ssh-terminal plugin, served at /plugin-ws/ssh-terminal/terminal, and removed /ssh/websocket/. Every `termix ssh` against a 2.9 server failed its handshake, which surfaces as "Unexpected server response: 502" behind Cloudflare. Try the plugin path first and fall back to /ssh/websocket/ when the server answers without upgrading, so servers older than 2.9 keep working. A refused credential, a refused connection or a timeout is reported straight away rather than retried. 2.9 also accepts the upgrade and then closes with 1008 for a missing or expired token, where older servers answered 401, so that close now gets the same `termix login` hint, and any other close carries the server's reason.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
termix sshcan't open a terminal on a Termix 2.9 server. 2.9 moved the terminal into the ssh-terminal plugin and removed/ssh/websocket/, the path the CLI connects to, so every handshake fails. Behind Cloudflare the error isCould not open the terminal connection: Unexpected server response: 502.WEBSOCKET_ENDPOINTSlists both terminal pathstermix sshconnects at/plugin-ws/ssh-terminal/terminaland falls back to/ssh/websocket/for servers older than 2.9Changes Made
src/terminal/ws-client.ts:TerminalSocket.open()tries/plugin-ws/ssh-terminal/terminalfirst, then/ssh/websocket/.1008 Authentication required. Older servers refused the handshake with a 401. That close now shows the same "runtermix login" hint, and any other close message includes the server's reason, e.g.The server closed the connection: Data access required.TERMIX_TERMINAL_URLhints: these now say they apply to backends older than 2.9. On 2.9 the terminal is served from the main backend port.plugins/ssh-terminal/src/backend/terminal-socket.tsatrelease-2.9.1-tagwith what the CLI sends, and nothing else differs:connectToHostand itsConnectToHostDatafields are the same.connected,passphrase_required,sessionAttached,data,error,session_ended) are the same.Authorization: BearerthroughextractWebSocketToken, the header the CLI already sends.Related Issues
Screenshots / Demos
Against a 2.9.1 server behind a Cloudflare Tunnel:
Tests: six new cases in
test/ws-client.test.ts:Authentication requiredcloseThe existing tests now run against the plugin path.
npm testpasses 165 of 165, and format, lint and type-check are clean.What hasn't been tested:
termix sshin a real TTY. The live test used--command, which goes through the same handshake andconnectToHostflow.npm run smokefails one check, "tarball contains the built entry point". It fails the same way on unmodifiedmainwith npm 12.0.2:npm pack --jsonoutput has a different shape there. CI pins npm 11, so I left it alone.Checklist