【问题标题】:Visual Studio Code: Trying setup Remote Debugging to AWS Ec2 Instance?Visual Studio Code:尝试为 AWS Ec2 实例设置远程调试?
【发布时间】:2019-02-26 23:24:44
【问题描述】:

所以我试图在 Visual Studio Code 上设置从本地机器到 ec2 实例的远程调试。 遇到错误:

launch.json 文件

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Remote",
            "address": "ec2..........-west-2.compute.amazonaws.com",
            "port": 3000,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/home/ubuntu/"
        }

    ]
}

错误:

使用检查器协议进行调试,因为无法使用 Node.js 版本 确定(错误:连接 ECONNREFUSED 52.182.32.72:3000)

无法连接到运行时进程,10000 毫秒后超时 - (原因: 无法连接到目标:连接 ECONNREFUSED 54.186.38.77:3000)。

另外

  1. 为了将 VS Code 与 ec2 连接,我需要设置一个项目吗 里面的文件夹先?
  2. 为此,我还需要先在 EC2 上安装 nodejs 吗?

我做错了什么?请帮忙!

【问题讨论】:

  • aws 实例入站安全组是否允许您在端口 3000 上的本地 ip 访问它?
  • 是的,端口 3000 已打开,我可以访问它...即 public ip:3000 -> 显示.. 但是错误仍然存​​在!

标签: amazon-web-services amazon-ec2 visual-studio-code remote-debugging


【解决方案1】:

要从 VS Code 连接 EC2,您需要安装 sftp 扩展。

  1. 打开 VS Code 然后输入 Ctrl + Shift + X 就会打开扩展窗口
  2. 在扩展窗口中输入“sftp”,然后点击“liximomo”开发的第一个扩展
  3. 按 Ctrl + Shift + P 然后输入 SFTP:Config
  4. 在打开的配置 json 文件中,根据您的 EC2 编辑“host”和“privateKeyPath”,如下所示

{

"name": "GIVE ANY NAME",
"host": "ec2-.........compute.amazonaws.com",
"protocol": "sftp",
"port": 22,
"username": "ec2-user",
"privateKeyPath": "SPECIFY YOUR PATH/FILENAME.pem",
"remotePath": "/",
"uploadOnSave": true

}

  1. 保存sftp.json文件,点击VS Code左侧菜单栏中添加的Remote Explorer按钮,在文件资源管理器中可以查看远程文件夹和文件

【讨论】:

    猜你喜欢
    • 2018-11-04
    • 2012-07-18
    • 1970-01-01
    • 2019-04-02
    • 2021-10-23
    • 2022-12-17
    • 1970-01-01
    • 2013-11-27
    • 1970-01-01
    相关资源
    最近更新 更多