Skip to content

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

@yaauie

Description

@yaauie

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'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions