Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Run remote Debug success,But restart Debug errorInfo-show: connect ECONNREFUSED ip-address:5678

未关闭
#1,582 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python, vscode
领域
devtools

调研方向

使用 launch.json、task.json 和 main.py 重现远程附加和重启流程,从 debugpy.listen() 和 debugpy.wait_for_client() 调用开始。检查第一次会话之后如何发起第二次附加,并验证重启会保持连接,而不是在端口 5678 上产生 ECONNREFUSED。

由索引模型根据 Issue 内容生成。

描述

bug

Environment data

  • OS: Ubuntu 22.04
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
  • debugpy version:1.8.1
  • Using VS Code or Visual Studio: VSCode 1.88.1, Terminal

Actual behavior

I can connect normally with debugging and debugging normally,But click to re -debug, you will prompt an error and exit the debugging

Expected behavior

If I click to restart the debugging, I should continue the normal debugging process
屏幕截图 2024-05-11 151348

error: connect ECONNREFUSED ip-address:5678
屏幕截图 2024-05-11 145746

Steps to reproduce:

vscode:
launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "connect to remote server",
            "type": "debugpy",
            "request": "attach",
            "preLaunchTask": "Run_Python",
            "connect": {
                "host": "ip-address",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/home/xxx/py/py/"
                }
            ],
            "justMyCode": true
        }
    ]
}

task.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run_Python",
            "type": "shell",
            "command": "ssh -tt xxx@ip-address 'python /home/xxx/py/py/main.py'",
            "args": [],
            "isBackground": true,
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": {
                "owner": "python",
                "source": "debugpy",
                "fileLocation": [
                    "relative",
                    "${workspaceFolder}"
                ],
                "pattern": [
                    {
                        "regexp": "\\s+(.*)$",
                        "message": 1
                    },
                    {
                        "regexp": "Connection to closed",
                        "file": 1,
                        "line": 1,
                        "column": 1
                    }
                ],
                "background": {
                    "activeOnStart": false,
                    "beginsPattern": {
                        "regexp": "start"
                    },
                    "endsPattern": {
                        "regexp": "Waiting for debugger attach"
                    }
                }
            },
            "presentation": {
                "echo": true,
                "panel": "shared",
                "focus": true,
                "clear": true
            }
        }
    ]
}

code:

print("start")
import debugpy

# 5678 is the default attach port in the VS Code debug configurations. Unless a host and port are specified, host defaults to 127.0.0.1
debugpy.listen(('0.0.0.0', 5678))
print("Waiting for debugger attach")
debugpy.wait_for_client()
debugpy.breakpoint()
def add_fun(a, b):
    a = a * 10
    b = b * 100
    c = a + b
    return c

if __name__ == '__main__':
    a = 10
    b = 78
    c = add_fun(a, b)
    c = c
    print(f"a + b = {c}")
主要语言
Python
星标
2.5k
派生
202
平均合并
5 天 1 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/debugpy 的其他 Issue

查看 microsoft/debugpy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。