Issue with getting RubyMine debugger to work with Docker - ruby-on-rails

I'm setting up RubyMine Debugger with Docker but I believe I have an issue with the matching the ports and I can't find documentation that thoroughly explains what the "configuration form in ruby mine is asking for and how to find the related information for the form input fields" all I can find is generic information.
I have had many error messages and even crashing when I click the debugger button. I have tried a lot more then what I'm posting but I never wrote it down. This is just where I am at this current moment
I have followed https://confluence.jetbrains.com/display/RUBYDEV/How+to+setup+and+run+ruby+remote+debug+session
I have added ports to the docker-compose.yml file.
Setup configuration for remote Remote Ruby SDK and Gem.
Setup Ruby remote debug configuration.
I have tried working my way through every error but I just get more as I go.
This app uses docker-compose and I'm not familiar with it at all other then all the reading I been doing to get this debugger setup
docker-compose.yml file
app:
build: wffffffe_api
dockerfile: Dockerfile-development
command: rails server --port 3000 --binding 0.0.0.0
stdin_open: true
tty: true
ports:
- "3000:3000"
- "1234:1234"
- "26162:26162"
volumes:
- './wfffffe_api:/var/www/weffffffe_api'
- './dotfiles/.vimrc-basic:/root/.vimrc'
The debugger configuration
Remote host: 0.0.0.0
Remote port: 3000
Remote root folder: /var/www/wffffffe_api
local port: 26162
local root folder: /Users/josh/Work/wffffffe_api
I have tried doing
docker-compose exec app rdebug-ide --host 0.0.0.0 --port 3000 --dispatcher-port 26162 -- bin/rails server
If the docker container is already running I get:
Fatal exception in DebugThread loop:
Address already in use - bind(2) for "0.0.0.0" port 3000
If the docker container is not already running I get:
Fast Debugger (ruby-debug-ide 0.6.1, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:3000
I then do docker-compose up --build -d
ERROR: for app Cannot start service app: b'driver failed programming external connectivity on endpoint work_app_1 (1e830daaecd39fab784b817a03893b592635542a8dfe3de69859c0ba7d39b483): Error starting userland proxy: Bind for 0.0.0.0:3000 failed: port is already allocated'
Do I need to have two separate servers running?

Your problem is that you are trying to debug on port 3000, which already bound by your rails application.
The --port of rdebug-ide specify the port that RubyMine will use for its debug protocol.
When you execute rails server --port 3000 --binding 0.0.0.0, you are binding port 3000 as your rails application (and not as debug port).
Change your remote port debug to 1234 (which you already exposed in your docker-compose.yml) and it should work.
To summarise, your command should look like:
docker-compose exec app rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- bin/rails server --port 3000 --binding 0.0.0.0

Related

Why docker container iptables permission denied?

I run docker container by docker-compose.yml file.
Below he setting for the container in problem.
test:
image: captainteemo/aips:1.0
container_name: test
hostname: test
volumes:
- /home/{{.Node.Hostname}}/share/hosts:/etc/hosts
- /home/{{.Node.Hostname}}/share/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
environment:
- LC_ALL=C.UTF-8
- LANG=C.UTF-8
- JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
privileged: true
cap_add:
- NET_ADMIN
tty: true
command: /sbin/init
ports:
- 8128:8128
deploy:
placement:
constraints:
- node.hostname == user1
The binding port is a port for back-end server access.
However, when running a backend server using uvicorn, access is not possible. Also, if i check the port with 'netstat', the 8128 port is not confirmed.
So after installing the 'iptables' package, I tried to open the port with the 'iptables -I INPUT 1-ptcp --dport 8128-j ACCEPT' command, but I get the same error as below.
iptables v1.6.1: can't initialize iptables table `filter': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
I tried to search this error and solution, but never is worked...
How can I solve it???
ADD. I start server by command by
uvicorn main:app --reload --host=0.0.0.0 --port=8128
but when I checked netstat, below result:
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:33727 0.0.0.0:* LISTEN -
ADD.
If I run server in 'user1' docker node, Below is print and stucked:
INFO: Will watch for changes in these directories: ['/home/zioz/server_place/test_web']
INFO: Uvicorn running on 0.0.0.0:8128 (Press CTRL+C to quit)
INFO: Started reloader process [531] using StatReload
If I run server in other(leader) docker node, Below is print and run well:
INFO: Will watch for changes in these directories: ['/home/zioz/server_place/test_web']
INFO: Uvicorn running on 0.0.0.0:8128 (Press CTRL+C to quit)
INFO: Started reloader process [531] using StatReload
INFO: Started server process [429]
INFO: Waiting for application startup.
INFO: Application startup complete.

Docker - eclipse-mosquitto:2.0.7 Error: Address not available

I'm trying to run mosquitto as docker container in windows 10. Getting below error log Address not available.
1614449526: mosquitto version 2.0.7 starting
1614449526: Config loaded from /mosquitto/config/mosquitto.conf.
1614449526: Starting in local only mode. Connections will only be possible from clients running on this machine.
1614449526: Create a configuration file which defines a listener to allow remote access.
1614449526: Opening ipv4 listen socket on port 1883.
1614449526: Opening ipv6 listen socket on port 1883.
**1614449526: Error: Address not available**
1614449526: mosquitto version 2.0.7 running
Could anyone advise how to solve this error?
Thank you.
I'd the same issue.
My solution was:
Enter to mosquitto container item from portainer.io. then you must loggin by console in mosquitto's container. Select command : /bin/sh for loggin...
Once into command line must to adjust the mosquitto.conf located in : /mosquitto/config
Must change the following parameters: Uncomment and fixed
listener 1883
persistence true
allow_anonymous true
later, exit from command console and restart mosquitto container...and ready !!
check logs!
Hope to help!
i followed Stéphane Trottier's suggestion but ran into issues b/c of the port and an outdated config change:
allow_anonymous true
listener 2883
protocol mqtt
i also used port 2883 instead since it seems 8883 is for tls so i was getting connection refused errors on the client and protocol errors on the server. my docker compose looks like this:
mqtt:
image: eclipse-mosquitto:latest
volumes:
- ./mqtt/config:/mosquitto/config
user: "1000:1000"
ports:
- 1883:2883
I had the same issue yesterday... Generally, some OSs require more permissions to run services on ports lower than 2000. This is how I made it work for me. I'm just running this for a hobby project. For work I would do things differently.
added local mosquitto folder and placed mosquitto.conf file in it.
added allow_anonymous true
changed port to something higher than 2000.
mount local config volume in docker
allow_anonymous true
port 8883
I run it via docker compose file.
version: '3.1'
services:
mosquitto:
image: eclipse-mosquitto
hostname: mosquitto
container_name: mosquitto
ports:
- "8883:8883"
volumes:
- ./mosquitto:/mosquitto/config
networks:
- webnet
networks:
webnet:
The error is gone from my logs and I can connect to it just fine on that port.
1614505908: The 'port' option is now deprecated and will be removed in a future version. Please use 'listener' instead.
1614505908: mosquitto version 2.0.7 starting
1614505908: Config loaded from /mosquitto/config/mosquitto.conf.
1614505908: Opening ipv4 listen socket on port 8883.
1614505908: Opening ipv6 listen socket on port 8883.
1614505908: mosquitto version 2.0.7 running
looks like I'll have to replace port with listener at some point soon.
both azegurelabs and Stéphane Trottier answers worked for me.
but the easier and more accurate solution is to just run image with default provided conf
docker run -it --rm --name mosquitto -p 1883:1883 eclipse-mosquitto:2.0 mosquitto -c /mosquitto-no-auth.conf
or to run image with your config file
docker run -it -p 1883:1883 -v <absolute-path-to-configuration-file>:/mosquitto/config/mosquitto.conf eclipse-mosquitto:<version>
you can read more here: mosquitto docker github page

Deploying rails docker on ec2 and redirecting traffic from 80 to 4000

I have a dockerized rails app that I am trying to deploy to aws ec2. I managed to make it run in docker on ec2 and map port 4000, docker_compose.yml :
app:
image: davidgeismar/artifacts-app:latest
command: 'rails server -p 4000'
ports:
- "4000:4000"
volumes:
- ./log/production.log:/artifacts_data_api/log/production.log
On the aws dashboard in security groups I allowed http traffic from any source :
HTTP TCP 80 0.0.0.0/0
I wanted to open port 3000 but it is not possible on aws dashboard. From what I understand I am now supposed to redirect traffic from port 80 to port 3000. I followed those instructions to do that : https://serverfault.com/questions/320614/how-to-forward-port-80-to-another-port-on-the-samemachine
Now when I try to access my application server through my brower using ipv4:public_instance_ip/80 or ipv4:public_instance_ip:80I always get :
This site can’t be reached
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
Could you provide guidance on how to achieve this ?

Travis CI: start rails server

I need to start a rails server on Travis to run integration tests.
I've added this to the config file:
before_script:
- psql -c 'create database scalia_test;' -U postgres
- "bundle exec rails server -p 3000 &"
However, I still get an error from Cypress:
http://localhost:3000/users/sign_in
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
> Error: connect ECONNREFUSED 127.0.0.1:3000
Common situations why this would fail:
- you don't have internet access
- you forgot to run / boot your web server
- your web server isn't accessible
- you have weird network configuration settings on your computer
The stack trace for this error is:
Error: connect ECONNREFUSED 127.0.0.1:3000
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150:14)
Does anybody knows how to start a Rails server on Travis ?
You are using & to send the command to the background, then you are running your tests right?
By the time you are running the tests Travis is still booting up your Rails server in the background therefore it's erroring out saying it can't connect. In my opinion it doesn't have to do anything with port binding.
In order to fix that you should use the -d parameter to daemonize rails after it started:
before_script:
- psql -c 'create database scalia_test;' -U postgres
- "bundle exec rails server -p 3000 -d"
rails server will block until it listens on port 3000 then sends itself to the background and continue running your scripts.
Do note that after your tests have run you may kill the rails server again using:
kill -9 $(cat tmp/pids/server.pid)
Otherwise you'll get a timeout or another error from travis.
Try binding rails to the loopback IP in that port
bundle exec rails s -p 3000 -b 127.0.0.1
probably that port is in use. Type lsof -i :8000 in terminal to see if that port is beeing used
U can try to start server with difrent port like rails server -p 3050

How do i run enketo-express on Ubuntu?

After setup of enketo express, When i run enketo-express using command "docker-compose up -d" on an ubuntu server, it shows an below error related to nginx
ERROR: for docker_nginx_1 Cannot start service nginx: b'driver failed programming external connectivity on endpoint docker_nginx_1 (7c414e255d50f42a0fa14d07c0b0d29125f666d77e55e5eb4437e43e3e4d9454): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use'
ERROR: for nginx Cannot start service nginx: b'driver failed programming external connectivity on endpoint docker_nginx_1 (7c414e255d50f42a0fa14d07c0b0d29125f666d77e55e5eb4437e43e3e4d9454): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use'
By default 80 port is used by the apache service on ubuntu server. This means you need to change your port.
Just try to Bind port 8081 of your ubuntu with the port 80 of the container. For this use this command,
$ run docker run -d -p 8081:80 --name webserver nginx
This creates the link you need to access it at http://localhost:8081/
Note- Change port in "setup/docker/docker-compose.yml" file. eg: 80:80 to 8081:80
It's because something is already running on port 80 on the host machine.
View which process it is, get the PID -
$ lsof -i:80
$ netstat -tulnap | grep :80
Kill the process -
$ kill -9 $PID
Try now & you will be good -
$ docker-compose up -d

Resources