Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after binding to socket and port in one config #1986

Closed
flaminestone opened this issue Sep 24, 2019 · 3 comments
Closed

Error after binding to socket and port in one config #1986

flaminestone opened this issue Sep 24, 2019 · 3 comments
Labels
Milestone

Comments

@flaminestone
Copy link

Puma can not to be configuring for work with socket and port in one time.
In previous version (4.1.1) all work fine.
Error:

Traceback (most recent call last):
	12: from /usr/local/bundle/bin/puma:23:in `<main>'
	11: from /usr/local/bundle/bin/puma:23:in `load'
	10: from /usr/local/bundle/gems/puma-4.2.0/bin/puma:10:in `<top (required)>'
	 9: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/cli.rb:80:in `run'
	 8: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/launcher.rb:172:in `run'
	 7: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/single.rb:98:in `run'
	 6: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/runner.rb:154:in `load_and_bind'
	 5: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/binder.rb:89:in `parse'
	 4: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/binder.rb:89:in `each'
	 3: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/binder.rb:107:in `block in parse'
	 2: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/binder.rb:107:in `each'
	 1: from /usr/local/bundle/gems/puma-4.2.0/lib/puma/binder.rb:111:in `block (2 levels) in parse'
/usr/local/bundle/gems/puma-4.2.0/lib/puma/binder.rb:111:in `ip_unpack': need IPv4 or IPv6 address (SocketError)

Puma config:

bind "unix:///puma.sock"
bind 'tcp://0.0.0.0:3000'

To Reproduce
File with application (app.rb):

require 'sinatra'
class App < Sinatra::Base
  get '/' do
    render 'ok!'
  end
end

File with puma config (config.puma.rb)

bind "unix:///puma.sock"
bind 'tcp://0.0.0.0:3000'

sinatra config (config.ru):

require_relative 'app'

run Rack::URLMap.new('/' => App)

configure do
  set :server, :puma
end

Gemfile:

source 'https://rubygems.org'
gem 'puma', '4.2.0'
# gem 'puma', '4.1.1'
gem 'sinatra'

Dockerfile:

FROM ruby:2.6.4
RUN mkdir /project
ADD . /project
WORKDIR /project
RUN bundler install
CMD puma -C config.puma.rb

I created a small project to reproduce this issue. It is attached to the issue.

I think this method has error.
@ios class instance is a array with TCPServer and UNIXServer objects
(addind TCPServer, addind UNIXServer), but this array is being processed only in tcp section (this).

project.zip

  • OS: Linux, Elementary OS Juno
  • Puma Version 4.1.1 and 4.2.0
@MSP-Greg
Copy link
Member

@flaminestone

This is a bug. But, I believe if you list the unix bindings last, it should work.

I wrote tests for both 'orderings', and I'll submit a PR...

@flaminestone
Copy link
Author

@MSP-Greg Yes, all works fine after changing bind position. Thank you for quick answer

@MSP-Greg
Copy link
Member

@flaminestone

Thanks for testing quickly. Next release should fix the issue (no work-around needed).

MSP-Greg added a commit to MSP-Greg/puma that referenced this issue Sep 29, 2019
1. Fix mult binds when unix is first, followed by ip bind.  See issue puma#1986.

2. When localhost is used for ssl or tcp, output actual ip's bound to.

3. Fix issues with IPv6 bind logging (brackets).

4. Move ssl context initialization code from Binder#parse to new method, #ssl_ctx_init.
@nateberkopec nateberkopec added this to the 4.2.1 milestone Sep 30, 2019
nateberkopec added a commit that referenced this issue Oct 1, 2019
This was referenced Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants