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

When host specified as string url, default port is 80 #625

Closed
yaauie opened this issue Mar 22, 2019 · 2 comments · Fixed by #651
Closed

When host specified as string url, default port is 80 #625

yaauie opened this issue Mar 22, 2019 · 2 comments · Fixed by #651

Comments

@yaauie
Copy link
Member

yaauie commented Mar 22, 2019

A bug was recently filed on the Logstash Elasticsearch Filter Plugin, indicating that specifying a schema in the host argument would cause the client to fail to provide the default port.

Defining a connection schema will override the default port (9200) for a given host.

Scenario: Elasticsearch node bound to loopback/localhost:

  • hosts => ["localhost:9200"] - works
  • hosts => ["localhost"] - works
  • hosts => ["http://localhost"] - doesn't work

-- logstash-plugins/logstash-filter-elasticsearch#110

The issue is that when we send URI#parse(String), URI finds the http/https implementation of URI, each of which have default ports that get set on the instance.

URI.parse('http://localhost').port # => 80

Although it's not particularly clean, the following will always create a URI::Generic (which has no default port):

URI::Generic.new(*URI.split('http://localhost'))
@estolfo
Copy link
Contributor

estolfo commented May 3, 2019

PR: #647

@estolfo estolfo closed this as completed May 3, 2019
@estolfo estolfo reopened this May 3, 2019
@estolfo
Copy link
Contributor

estolfo commented May 6, 2019

Further updates:
#649
467f473

@estolfo estolfo closed this as completed May 6, 2019
estolfo pushed a commit that referenced this issue May 7, 2019
picandocodigo pushed a commit to elastic/elastic-transport-ruby that referenced this issue Jun 7, 2021
renaperes824 added a commit to renaperes824/ruby-elastic-transport that referenced this issue Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants