Unable to debug Rails app running on docker from Rubymine

I am trying to start my debugger for my rails app thats running on docker. I followed the tutorial on this post and created a new remote sdk based on my docker-compose.yml file. I am running Rubymine 2018.1

 

 

 

If i run the app, it runs fine, but in debugger mode I get the below. Am I missing some configuration thats preventing to from connecting. Thanks

[36mscinote_web_development |[0m Fast Debugger (ruby-debug-ide 0.6.1, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:1234
[36mscinote_web_development |[0m => Booting Puma
[36mscinote_web_development |[0m => Rails 5.1.1 application starting in development on http://0.0.0.0:3000
[36mscinote_web_development |[0m => Run `rails server -h` for more startup options
[36mscinote_web_development |[0m [sciNote] Generating symlinks for addons!
[36mscinote_web_development |[0m [sciNote] Copying features from addons!
[36mscinote_web_development |[0m [1] Puma starting in cluster mode...
[36mscinote_web_development |[0m [1] * Version 3.11.2 (ruby 2.4.3-p205), codename: Love Song
[36mscinote_web_development |[0m [1] * Min threads: 5, max threads: 5
[36mscinote_web_development |[0m [1] * Environment: development
[36mscinote_web_development |[0m [1] * Process workers: 2
[36mscinote_web_development |[0m [1] * Preloading application
[36mscinote_web_development |[0m [1] * Listening on tcp://0.0.0.0:3000
[36mscinote_web_development |[0m [1] Use Ctrl-C to stop
[36mscinote_web_development |[0m Fast Debugger (ruby-debug-ide 0.6.1, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:46329
[36mscinote_web_development |[0m Fast Debugger (ruby-debug-ide 0.6.1, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:41581
[36mscinote_web_development |[0m 9: connection failed(1)
[36mscinote_web_development |[0m Exception: Connection refused - connect(2) for "172.18.0.1" port 26168
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:153:in `initialize'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:153:in `open'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:153:in `block in notify_dispatcher'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:151:in `times'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:151:in `notify_dispatcher'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:116:in `block in start_control'
[36mscinote_web_development |[0m /usr/local/bundle/gems/logging-2.0.0/lib/logging/diagnostic_context.rb:448:in `block in create_with_logging_context'
[36mscinote_web_development |[0m 12: connection failed(1)
[36mscinote_web_development |[0m Exception: Connection refused - connect(2) for "172.18.0.1" port 26168
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:153:in `initialize'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:153:in `open'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:153:in `block in notify_dispatcher'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:151:in `times'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:151:in `notify_dispatcher'
[36mscinote_web_development |[0m /usr/local/bundle/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide.rb:116:in `block in start_control'
[36mscinote_web_development |[0m /usr/local/bundle/gems/logging-2.0.0/lib/logging/diagnostic_context.rb:448:in `block in create_with_logging_context'
[36mscinote_web_development |[0m 9: connection failed(2)

1 comment

I have the same issue with my webapp, which is in 'cluster mode' (workers ENV.fetch('PUMA_WORKERS') { 1 }). Well, it is almost the same issue, as it RubyMine connects to the debugger but the requests hang/get frozen.

In single mode (workers ENV.fetch('PUMA_WORKERS') { 0 }) there is no issue.

On the other hand, with the sample project from the Using Docker Compose as a Remote Interpreter tutorial I have no issues.

These are the outputs of both projects in debug mode : 

  • Sample project 
Starting dockerrailsapp_web_1 ...
Attaching to dockerrailsapp_web_1
web_1 | Fast Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.3.beta2, file filtering is supported) listens on 0.0.0.0:1234
web_1 | => Booting Puma
web_1 | => Rails 5.0.7 application starting in development on http://0.0.0.0:3000
web_1 | => Run `rails server -h` for more startup options
web_1 | Puma starting in single mode...
web_1 | * Version 3.12.0 (ruby 2.4.4-p296), codename: Llamas in Pajamas
web_1 | * Min threads: 5, max threads: 5
web_1 | * Environment: development
web_1 | * Listening on tcp://0.0.0.0:3000
web_1 | Use Ctrl-C to stop

root@6a95c86a7996:/opt/project# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 5 12:58 ? 00:00:01 puma 3.12.0 (tcp://0.0.0.0:3000) [project]
root 25 0 0 12:58 pts/0 00:00:00 bash
root 36 25 0 12:58 pts/0 00:00:00 ps -ef

root@6a95c86a7996:/opt/project# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN 1/puma 3.12.0 (tcp:
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 1/puma 3.12.0 (tcp:
tcp 0 0 127.0.0.11:41657 0.0.0.0:* LISTEN -
udp 0 0 127.0.0.11:43779 0.0.0.0:* -

  • My webapp
web_1 | The Gemfile dependencies are satisfied
web_1 | Fast Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:1234
web_1 | => Booting Puma
web_1 | => Rails 4.2.10 application starting in development on http://0.0.0.0:3000
web_1 | => Run `rails server -h` for more startup options
web_1 | => Ctrl-C to shutdown server
web_1 | root ............................................ *debug -T
web_1 | - <Appenders::Stdout name="stdout">
web_1 | - <Appenders::RollingFile name="file">
web_1 | - <Appenders::File name="logmatic">
web_1 | ActionMailer::Base ............................ debug +A -T
web_1 | ActionView::Base .............................. debug +A -T
web_1 | ActiveRecord::Base ............................ debug +A -T
web_1 | ActiveSupport::Cache::FileStore ............... debug +A -T
web_1 | ActiveSupport::Dependencies ................... debug +A -T
web_1 | Logging ....................................... *off -A -T
web_1 | Rails ......................................... debug +A -T
web_1 | [1] Puma starting in cluster mode...
web_1 | [1] * Version 3.12.0 (ruby 2.3.7-p456), codename: Llamas in Pajamas
web_1 | [1] * Min threads: 1, max threads: 1
web_1 | [1] * Environment: development
web_1 | [1] * Process workers: 1
web_1 | [1] * Phased restart available
web_1 | [1] * Listening on tcp://0.0.0.0:3000
web_1 | [1] Use Ctrl-C to stop
web_1 | Subprocess Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:40125
web_1 | [1] ! Terminating timed out worker: 14
web_1 | Subprocess Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:46479

root@d7830bcd9cb4:/opt/project# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 7 12:19 pts/0 00:00:07 puma 3.12.0 (tcp://0.0.0.0:3000) [project]
root 18 0 0 12:19 pts/1 00:00:00 bash
root 66 1 0 12:20 pts/0 00:00:00 puma 3.12.0 (tcp://0.0.0.0:3000) [project]
root 71 18 0 12:20 pts/1 00:00:00 ps -ef

root@d7830bcd9cb4:/opt/project# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.11:42763 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:46479 0.0.0.0:* LISTEN 66/puma 3.12.0 (tcp
tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN 1/puma 3.12.0 (tcp:
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 1/puma 3.12.0 (tcp:

I'm on

- Ubuntu 18.04.1 LTS

- RubyMine 2018.2.2

- docker-compose version 1.22.0, build f46880fe

- Docker version 18.06.1-ce, build e68fc7a

- 'rails', '4.2.10'

- ruby 2.3.7

 

You can reproduce it using the sample project using a Puma config file with 1 worker and launching the debugger. Hope It will helps to fix this issue.

 

 

=== Update 2 hours later ====

The console log when using enabling 'Settings | Build, Execution & Deployment | Debugger | Ruby | Verbose debugger output'


web_1 | The Gemfile's dependencies are satisfied
web_1 | Fast Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:1234
web_1 | Connected from 172.19.0.1
web_1 | 1: Starting control thread
web_1 | 1: Processing in control: b /opt/project/app/controllers/public_api/v1/main_controller.rb:212
web_1 | 1: <breakpointAdded no="1" location="/opt/project/app/controllers/public_api/v1/main_controller.rb:212"/>
web_1 | 1: Processing in control: b /opt/project/app/controllers/public_api/v1/main_controller.rb:76
web_1 | 1: <breakpointAdded no="2" location="/opt/project/app/controllers/public_api/v1/main_controller.rb:76"/>
web_1 | 1: Processing in control: start
web_1 | 1: Starting: running program script
web_1 | => Booting Puma
web_1 | => Rails 4.2.10 application starting in development on http://0.0.0.0:3000
web_1 | => Run `rails server -h` for more startup options
web_1 | => Ctrl-C to shutdown server
web_1 | [1] Puma starting in cluster mode...
web_1 | [1] * Version 3.12.0 (ruby 2.3.7-p456), codename: Llamas in Pajamas
web_1 | [1] * Min threads: 1, max threads: 1
web_1 | [1] * Environment: development
web_1 | [1] * Process workers: 1
web_1 | [1] * Phased restart available
web_1 | [1] * Listening on tcp://0.0.0.0:3000
web_1 | [1] Use Ctrl-C to stop
web_1 | Subprocess Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:39833
web_1 | 14: Ide process dispatcher notified about sub-debugger which listens on 39833
web_1 |
web_1 | [1] ! Terminating timed out worker: 14
web_1 | Subprocess Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:43179
web_1 | 18: Ide process dispatcher notified about sub-debugger which listens on 43179
web_1 |

This is the RubyMine log when using 1 Puma worker :  

2018-09-07 18:23:03,694 [11927531] INFO - .CloudSilentLoggingHandlerImpl - Creating container... 
2018-09-07 18:23:52,938 [11976775] ERROR - debugger.RubyProcessDispatcher - Failed to connect to process at localhost:39833
org.rubyforge.debugcommons.RubyDebuggerException: Cannot connect to the debugged process at port 39833 in 10s:

[Remote Process at localhost:39833]
at org.rubyforge.debugcommons.RubyDebuggerProxy.a(RubyDebuggerProxy.java:748)
at org.rubyforge.debugcommons.RubyDebuggerProxy.e(RubyDebuggerProxy.java:719)
at org.rubyforge.debugcommons.RubyDebuggerProxy.getCommandSocket(RubyDebuggerProxy.java:403)
at org.rubyforge.debugcommons.RubyDebuggerProxy.a(RubyDebuggerProxy.java:163)
at org.rubyforge.debugcommons.RubyDebuggerProxy.attach(RubyDebuggerProxy.java:135)
at org.jetbrains.plugins.ruby.ruby.debugger.impl.RubyDebugProcess.attachToProxy(RubyDebugProcess.java:260)
at org.jetbrains.plugins.ruby.ruby.debugger.RubyProcessDispatcher.b(RubyProcessDispatcher.java:107)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at org.rubyforge.debugcommons.RubyDebuggerProxy.e(RubyDebuggerProxy.java:696)
... 11 more
2018-09-07 18:23:52,943 [11976780] ERROR - debugger.RubyProcessDispatcher - RubyMine 2018.2.2 Build #RM-182.4129.29
2018-09-07 18:23:52,944 [11976781] ERROR - debugger.RubyProcessDispatcher - JDK: 1.8.0_152-release
2018-09-07 18:23:52,944 [11976781] ERROR - debugger.RubyProcessDispatcher - VM: OpenJDK 64-Bit Server VM
2018-09-07 18:23:52,945 [11976782] ERROR - debugger.RubyProcessDispatcher - Vendor: JetBrains s.r.o
2018-09-07 18:23:52,945 [11976782] ERROR - debugger.RubyProcessDispatcher - OS: Linux
2018-09-07 18:23:52,945 [11976782] ERROR - debugger.RubyProcessDispatcher - Last Action: Debug
 

=====PERFORMANCE SUMMARY=====
Filesystem Info:
File system is case sensitive: true
Are there symlinks: false
Number of files: 10161

System Info:
Number of CPU: 4
Used memory: 532Mb
Free memory: 192Mb
Total memory: 725Mb
Maximum available memory: 725Mb
Displays:
Display 0: 1920x1080; scale: 1.00

Project Info:
Number of opened files: 10
File size (in lines): 37
File size in characters: 1423
Last action: _Undo
Number of injections: 0

IDE Info:
Custom plugins: [BashSupport (1.6.13.182)]
Disabled plugins:[]
Build version: RubyMine 2018.2.2 Build #RM-182.4129.29 August 20, 2018
Java version: 1.8.0_152-release-1248-b8amd64
Operating System: Linux (4.15.0-33-generic, amd64)
JVM version: OpenJDK 64-Bit Server VM JetBrains s.r.o

I wonder if it is related to https://youtrack.jetbrains.com/issue/RUBY-21375 

0

Please sign in to leave a comment.