paramiko / paramiko/paramiko

connection.recv() timeout

Open
#2,061 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Hangs Support
Dominant language
Python
Stars
9.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Hello!

I am trying to connect to a console via SSH terminal server
When the server port does not have any console connected or the device is powered off the

connection.send(b"\n")
connection.recv(4096)

does not return any output, so the scrip gets stuck. How can I set a short timeout value?

 ssh.connect(term_serv_ip_address, port=term_serv_ssh_port, username=term_serv_user,
                        password=term_serv_passw)
            connection = ssh.invoke_shell()
            connection.send(b"\n")
            time.sleep(.5)

            # login
            output = connection.recv(4096).decode('utf-8')
            hostn = re.search(r'<(ipi-\w{3,4}\d{3,4}-r-al-\d{2})>', output)
            print(output)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the connection.recv(4096) call after invoke_shell() in the provided example and review how Paramiko handles reads when the remote console is unavailable. Reproduce the no-console or powered-off case and verify that a short timeout can be configured and that recv returns or raises within that interval.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.