netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
567 stars 168 forks source link

Is it possible to use pynetbox library with http/2 ? #540

Closed satperm closed 1 year ago

satperm commented 1 year ago

My Netbox app is deployed in AWS EKS cluster, web part of the app is behind ELB with http/2 target group. When i tried to request api object with simplest code i received error 464

import pynetbox
TOKEN = 'supersecrettokern'
NETBOX = 'https:/<fqdn>'
nb = pynetbox.api(NETBOX, TOKEN)
devices = nb.dcim.devices.all()
for device in devices:
    print(device)

error

pynetbox.core.query.RequestError: The request failed with code 464  but more specific details were not returned in json. Check the NetBox Logs or investigate this exception's error attribute.

Part of aws documetation

Protocol version

By default, Application Load Balancers send requests to targets using HTTP/1.1. You can use the protocol version to send requests to targets using HTTP/2 or gRPC.

The following table summarizes the result for the combinations of request protocol and target group protocol version.
Request protocol    Protocol version    Result
HTTP/1.1            HTTP/1.1    Success
HTTP/2              HTTP/1.1    Success
gRPC                HTTP/1.1    Error
HTTP/1.1            HTTP/2      Error
HTTP/2              HTTP/2      Success
gRPC                HTTP/2      Success if targets support gRPC
HTTP/1.1            gRPC        Error
HTTP/2              gRPC        Success if a POS
T request
gRPC                gRPC        Success

should i use specific target group with http/1.1 support? is it any chance to use pynetbox with http/2?

thanks in advance!

jcollie commented 1 year ago

pynetbox uses requests under the hood. requests does not appear to support http/2 yet so I don't think it's possible.

satperm commented 1 year ago

@jcollie thanks, is it possible to wrap pynetbox with something like httpx?