Skip to content

fix(ssh/telnet): resolve terminal hang on passive consoles and legacy devices#1236

Open
eduardomozart wants to merge 3 commits intognmyt:mainfrom
eduardomozart:patch-18
Open

fix(ssh/telnet): resolve terminal hang on passive consoles and legacy devices#1236
eduardomozart wants to merge 3 commits intognmyt:mainfrom
eduardomozart:patch-18

Conversation

@eduardomozart
Copy link
Copy Markdown
Contributor

@eduardomozart eduardomozart commented Mar 6, 2026

📋 Description

This PR fixes a critical issue where the terminal fails to initialize or open when connecting to passive environments, such as the Serial Consoles (OCI/AWS/GCP), Terminal Servers (Digi/Cyclades), and Legacy Network Switches (Cisco/HP/3Com).

The Problem: The "Silence Deadlock"

Nexterm's connection logic (both for SSH and Telnet) appears to be reactive, often waiting for the first stream of data from the remote host to fully transition the UI from a "Connecting" state to an active session.

Many serial-over-network bridges and legacy devices remain completely silent until they receive an initial "Enter" from the client. This creates a deadlock:

  1. The socket connection is technically established.
  2. The server waits for client input to show a prompt.
  3. The Nexterm UI remains stuck (or fails to open the terminal window) because it hasn't received the initial data event from the server.

The Solution: Proactive Session Trigger

Inspired by Netmiko's session establishment mechanism (_test_channel_read), I've implemented a triggerPassiveSession helper in ConnectionService.js.

How it works:

  • Initialization Nudge: If no data is received within 300ms of the connection being established, the function proactively sends a newline (\x0A).
  • UI Wake-up: This newline forces the remote buffer to flush, triggering the data event that Nexterm needs to successfully initialize and open the terminal UI.
  • Clean Start: The nudge is followed by an ANSI escape sequence (\x1B[2J\x1B[H) to clear the terminal. This ensures that the user starts with a clean, professional-looking terminal.

Safety & Performance

  • Self-Cleaning: The internal timer is automatically cleared upon the first data, error, or close event, preventing any "ghost" inputs.
  • Transparent for Standard Servers: Most Linux servers provide a banner/MOTD in < 100ms. In these cases, the timer is destroyed before firing, making the fix completely invisible and non-intrusive for standard SSH/Telnet connections.

🚀 Changes made to ...

  • 🔧 Server
  • 🖥️ Client
  • 📚 Documentation
  • 🔄 Other: ___

✅ Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have looked for similar pull requests in the repository and found none
  • This pull request does not contain translations (translations are managed through Crowdin)

🔗 Related Issues

Added a function to trigger a passive SSH session by sending a newline character, ensuring compatibility with silent devices.
Added triggerPassiveSession function to initiate SSH/Telnet sessions.
@eduardomozart eduardomozart changed the title Implement triggerPassiveSession for SSH streams Implement triggerPassiveSession for SSH/Telnet streams Mar 6, 2026
@eduardomozart eduardomozart changed the title Implement triggerPassiveSession for SSH/Telnet streams fix(ssh/telnet): resolve terminal hang on passive consoles and legacy devices Mar 6, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 6, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant