Vscode-ruby: Fatal exception in DebugThread loop when calling two debuggers

Created on 8 May 2018  路  8Comments  路  Source: rubyide/vscode-ruby

I have the following error when I'm trying run Sidekiq and Rails from Visual Studio code:
~
Fatal exception in DebugThread loop: Address already in use - bind(2) for "127.0.0.1" port 1234
Backtrace:
/Users/cameron/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:114:in initialize' from: /Users/cameron/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:114:innew'
from: /Users/cameron/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:114:in `block in start_control'
WARN: Unresolved specs during Gem::Specification.reset:
rake (>= 0.8.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
~

The launch.json looks as follows:
~
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for rdebug-ide",
"type": "Ruby",
"request": "attach",
"cwd": "${workspaceRoot}",
"remoteHost": "127.0.0.1",
"remotePort": "1234",
"remoteWorkspaceRoot": "${workspaceRoot}"
},
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server",
"-p",
"3131"
]
},
{
"name": "Sidekiq",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/bundle",
"args": [
"exec",
"sidekiq"
]
}
],
"compounds": [
{
"name": "Server/Client",
"configurations": ["Rails server", "Sidekiq"]
}
]
}
~

Even if I try and call them separately or using the compound I get that error. I'm only able to get sidekiq running with my Rails app by calling bundle exec sidekiq manually in the terminal.

Why am I getting this error?

Operating system: macOS High Sierra
VS Code: Version 1.22.2 (1.22.2)

stale

Most helpful comment

hi, i had same error today.
i searched this error, and hit below similar problem(and approach)!!
(in Japanese) 銇掞紒銉兗銈儷銈点兗銉愩兗銈掑垏銈夈仛銇偪銉笺儫銉娿儷銈掓秷銇椼仭銈冦仯銇燂紒
i think this error caused by you got off the terminal without turning off the local server.

you may solve this problem with 2steps.

  1. run below command in terminal with port number after IP address
lsof -i :1234
# in my case
#=> COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
#=> ruby    83410 username    7u  IPv4 0x992a0bd9da1c7fdf      0t0  TCP localhost:sear

this command indicates process lists connect currently.

  1. run below command to kill this port proccess.
kill -QUIT <PID>
# in mycase 
# kill -QUIT 83410

and It became available.
i hope my comments help you!!

All 8 comments

Any updates on this issue? Thanks

I am not currently taking a look at debugger issues. If you can debug and submit a PR that'd be helpful!

hi, i had same error today.
i searched this error, and hit below similar problem(and approach)!!
(in Japanese) 銇掞紒銉兗銈儷銈点兗銉愩兗銈掑垏銈夈仛銇偪銉笺儫銉娿儷銈掓秷銇椼仭銈冦仯銇燂紒
i think this error caused by you got off the terminal without turning off the local server.

you may solve this problem with 2steps.

  1. run below command in terminal with port number after IP address
lsof -i :1234
# in my case
#=> COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
#=> ruby    83410 username    7u  IPv4 0x992a0bd9da1c7fdf      0t0  TCP localhost:sear

this command indicates process lists connect currently.

  1. run below command to kill this port proccess.
kill -QUIT <PID>
# in mycase 
# kill -QUIT 83410

and It became available.
i hope my comments help you!!

DUPLICATED
Maybe?

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for rdebug-ide For Rails server",
            "type": "Ruby",
            "request": "attach",
            "cwd": "${workspaceRoot}",
            "remoteHost": "127.0.0.1",
            "remotePort": "1235", // new debugger proccess
            "remoteWorkspaceRoot": "${workspaceRoot}"
        },
        {
            "name": "Rails server",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/bin/rails",
            "args": [
                "server",
                "-p",
                "3131"
            ],
            "debuggerPort": "1235" // needed debugger
        },
        {
            "name": "Sidekiq",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/bin/bundle",
            "args": [
                "exec",
                "sidekiq"
            ]
        }
    ],
    "compounds": [
        {
            "name": "Server/Client",
            // add proccess for Rails server
            "configurations": ["Rails server", "Sidekiq", "Listen for rdebug-ide For Rails server]
        }
    ]
}

@golubov-andrey Have you tried that? If so, tell me so that I will try it too.

@minkir014 I have a new experement.
Example:
Needed debugging two services: zion-admin, platfrom-accounts etc.

I make config for platform-accounts:
_platform-accounts/.vscode/launch.json_

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "platform-accounts-server",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/bin/rails",
            "args": [
                "server", "--port=3001"
            ],
            "debuggerPort": "13001"
        }
    ]
}

and zion-admin:
_zion-admin/.vscode/launch.json_

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "platform-admin-server",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/bin/rails",
            "args": [
                "server"
            ],
            "debuggerPort": "13000"
        }
    ],
    "compounds": [
        {
            "name": "admin",
            "configurations": ["platform-accounts-server", "platform-admin-server"]
        }
    ]
}

Start debugging for compounds "admin":

golubov@agolubov-pc:~$ lsof -i :13000
COMMAND  PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
code    6550 golubov   22u  IPv4 703915      0t0  TCP localhost:57586->localhost:13000 (ESTABLISHED)
ruby    6569 golubov    9u  IPv4 704882      0t0  TCP localhost:13000 (LISTEN)
ruby    6569 golubov   10u  IPv4 704883      0t0  TCP localhost:13000->localhost:57586 (ESTABLISHED)
golubov@agolubov-pc:~$ lsof -i :13001
COMMAND  PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
code    6549 golubov   22u  IPv4 702451      0t0  TCP localhost:56452->localhost:13001 (ESTABLISHED)
ruby    6571 golubov    9u  IPv4 702449      0t0  TCP localhost:13001 (LISTEN)
ruby    6571 golubov   10u  IPv4 702450      0t0  TCP localhost:13001->localhost:56452 (ESTABLISHED)

For each proccesses needed custom debuggerPort in launch.json
Breakpoints is working!

p.s. sry my *%1!@ english:)

Thank you.

This issue has not had activity for 30 days. It will be automatically closed in 7 days.

Was this page helpful?
0 / 5 - 0 ratings