Failed to find free socket port for process dispatcher

Answered

My scenario is pretty much this one.

There's a Docker Compose running rails with:

ports:
- "3000:3000"
- "1234:1234"
- "26162:26162"

With gems:

Using debase 0.2.2.beta10
Using ruby-debug-ide 0.6.1

The command:

bundle exec rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- \
/app/bin/rails server -b 0.0.0.0 -p 3000 -e development'

That yelds:

Fast Debugger (ruby-debug-ide 0.6.1, debase 0.2.2.beta10, file filtering is supported) listens on 0.0.0.0:1234

The configuration for remote debug on RubyMine:

Remote host: 127.0.0.1
Remote port: 1234
Remote root folder: /app
Local port: 26162
Local root folder: /path/to/src

The result of Ctrl+Shift+F9:

Error running 'develop': Failed to find free socket port for process dispatcher

The very same configuration on VSCode just works flawlessly:

{
"version": "0.2.0",
"configurations": [
{
"name": "rdebug-ide",
"type": "Ruby",
"request": "attach",
"cwd": "${workspaceRoot}/src",
"remoteHost": "127.0.0.1",
"remotePort": "1234",
"remoteWorkspaceRoot": "/app"
},
]
}

This is frustrating.

14 comments
Comment actions Permalink

I'm running into the same scenario. If I launch my app without docker, my remote debugger can connect fine. But when I launch with Docker, it runs into the "failed to find... port..." error. I have the correct ports opened up in my docker compose file like so:

command: sh -c 'rm -rf ./tmp && bundle exec rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- bin/rails s -b 0.0.0.0'
ports:
- 3000:3000
- 1234:1234
- 26162:26162
0
Comment actions Permalink

Hello,

it's possible to add docker-compose Ruby SDK and launch debugging session using it (that is, without remote debug). Have you tried that?

0
Comment actions Permalink

I'll try to experiment with that some time (sorry for not giving it a shot right now).

I was able to track this down - https://github.com/ruby-debug/ruby-debug-ide/issues/107 It seems that something around the combination of docker and Rubymine causes a random port (in the ephemeral range, I think) to be used for the actual debugging, but the docker container doesn't have that port opened. Without digging into it further, I can't say whether the issue is with that gem or with Rubymine, but it looks like the gem maintainers are trying to implement a workaround/fix.

0
Comment actions Permalink

Same exact issue for me with PyCharm.  I have to start the app then start the server (container).  If I want to restart the app then I need to stop the container before restarting the app.

0
Comment actions Permalink

This is a problem with a Rack application:

  • RubyMine: 2020.1.3
  • Windows 10: 1909 (OS Build 18363.959)
  • Docker Desktop: 2.3.0.3 (45519)
  • Docker: 19.03.8, build afacb8b
  • Docker Compose: 1.25.5, build 8a1c60f6
  • Ruby Image: ruby:2.6.6
  • Gems:
    -puma: 4.3.5
    - rack: 2.2.3
    - debase:0.2.4.1
    - ruby-debug-ide: 0.7.2

But works in Visual Studio Code.

 

1
Comment actions Permalink

Are there any updates on this issue?

 

I've never been able to attach a debugger because of this and this is the only reason why I'd want to use RubyMine. This works perfectly fine with VS Code like others have mentioned, so it is something that can be fixed on RubyMine

0
Comment actions Permalink

Same problem in RubyMine: 2020.1.4.

0
Comment actions Permalink

In case there's an issue with connecting to Docker in PyCharm it'd be better to submit an issue on its tracker

As for RubyMine, there's a similar issue regarding ports so could you please check it: https://youtrack.jetbrains.com/issue/RUBY-25140 If it's not the case then a project sample with steps for reproduce would be great. You can also check whether it works for you with our sample app

0
Comment actions Permalink

Thanks for the response Olga!

When I try to follow all instructions in the sample app you provided, I got the following error:

Webpacker::Manifest::MissingEntryError in StaticPages#home

Showing /sample_rails_application/app/views/layouts/application.html.erb where line #12 raised:

Webpacker can't find application in /sample_rails_application/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
Also, if I attempt to follow a similar setup to that app in my project, I get a 'Error running "Development: app": Index 0 out of bounds for length 0'.I think this more closely resembles this reported issue: https://youtrack.jetbrains.com/issue/RUBY-25110

0
Comment actions Permalink

Oh also on the sample application I am seeing the following error in the logs: `Exception: Connection refused - connect(2) for "172.30.0.1" port 26168`

0
Comment actions Permalink

This also fails for RubyMine 2020.2 BETA

0
Comment actions Permalink

RUBY-25140 seems different from the problem I reported.  I get this

 

using this docker-compose.yml

version: "3.8"
services:
app:
build:
context: .
args:
APP_ROOT: /usr/src/app/
volumes:
- .:/usr/src/app/
ports:
- "9292:9292"
- "1234:1234"
- "26162:26162"
working_dir: /usr/src/app/
command: rdebug-ide --debug --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- /usr/local/bundle/bin/rackup --port 9292 --host 0.0.0.0


And this Ruby remote debug:



1
Comment actions Permalink

Hi Lnorth - this probably won't change anything for you, but you misspelled your Remote root folder. Looks like it should be /usr/src/app

Please keep this thread updated if you figure anything else out. This has been frustrating me for months because I want to debug in docker and have not been able to yet. I can in VS Code but then they don't have the "Ignore non-project files" option on the debugger so nothing is ideal right now.

0
Comment actions Permalink

Socketman, Thanks for the correction.  Same result after fixing the remote root.

 

0

Please sign in to leave a comment.