Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

connection to couchdb server via ipv6 address does not work #461

Closed
ManfredEnning opened this issue Mar 21, 2020 · 2 comments
Closed

connection to couchdb server via ipv6 address does not work #461

ManfredEnning opened this issue Mar 21, 2020 · 2 comments
Labels
Milestone

Comments

@ManfredEnning
Copy link

Please read these guidelines before opening an issue.

Bug Description

cloudant.couchdb does not work with ipv6 server addresses like
http://[fd78:3214:6290:d772::1:51]:5984

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

    with cloudant.couchdb('admin', '@@@', url='http://[fd78:3214:6290:d772::1:51]:5984') as db:
        print(db)

2. What you expected to happen

the couchdb server should be connected

3. What actually happened

requests.exceptions.InvalidURL: Failed to parse: http://fd78:3214:6290:d772::1:51:5984/_session

Environment details

Python 3.6

Remark:

the erroneous code can be found in the constructor of CouchDB()

            self.server_url = parsed_url._replace(
                netloc="{}:{}".format(parsed_url.hostname, parsed_url.port)).geturl()

here netloc is composed from parsed_url.hostname (without brackets) and the port number

the behaviour can easily be corrected by replacing with

           # is hostname a ipv6 address?
           if ':' in parsed_url.hostname:
                # yes: apply brackets
                self.server_url = parsed_url._replace(
                    netloc="[{}]:{}".format(parsed_url.hostname, parsed_url.port)).geturl()
            else:
                self.server_url = parsed_url._replace(
                    netloc="{}:{}".format(parsed_url.hostname, parsed_url.port)).geturl()
@emlaver
Copy link
Member

emlaver commented Mar 23, 2020

@ManfredEnning thanks for catching this! We'll add it to our backlog. Would you be interested in opening a PR?

@emlaver emlaver added the bug label Mar 23, 2020
@ricellis ricellis added this to the 2.next milestone Nov 20, 2020
@ricellis ricellis modified the milestones: 2.next, 2.later Aug 26, 2021
@ricellis
Copy link
Member

Closing; this library is now EOL.
IPv6 addresses work correctly in our replacement cloudant-python-sdk.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants