Skip to content

Conversation

magicnat
Copy link
Contributor

Hey colleagues,

I found two issues when trying to use the gNMI client with literal IPv6 address.

The string __target_path was constructed before brackets are added around the IPv6 address, causing issue with gRPC:

grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
    status = StatusCode.UNAVAILABLE
    details = "errors resolving 2001:db8::1:57400: [field:hostname lookup error:address lookup failed for 2001:db8::1:57400: Domain name not found]"
    debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2025-02-21T15:46:41.57215963-08:00", grpc_status:14, grpc_message:"errors resolving 2001:db8::1:57400: [field:hostname lookup error:address lookup failed for 2001:db8::1:57400: Domain name not found]"}"

Another issue arises when IPv6 is used and the certificate is not provided. The client attempts to retrieve the certificate from the device using ssl.get_server_certificate(). ssl.get_server_certificate() expect IPv6 address w/o enclosing brackets. With brackets it interprets the address as a domain, leading to the following error:

The SSL certificate cannot be retrieved from ('[2001:db8::1]', '57400')
Traceback (most recent call last):
  File "<REDACTED>/pygnmi/client.py", line 145, in connect
    ssl_cert = ssl.get_server_certificate(
  File "<REDACTED>/lib/python3.10/ssl.py", line 1523, in get_server_certificate
    with create_connection(addr, timeout=timeout) as sock:
  File "<REDACTED>/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "<REDACTED>/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

This PR addresses both of the issues.

@akarneliuk akarneliuk merged commit a8b5d12 into akarneliuk:master Mar 10, 2025
1 check failed
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 this pull request may close these issues.

2 participants