go-octopusdeploy icon indicating copy to clipboard operation
go-octopusdeploy copied to clipboard

[BUG] net/http throwing http2: no cached connection was available

Open conradj3 opened this issue 11 months ago • 0 comments

Description It seems there is a bug with net/http package, when leverage Golang version go1.23.2. When attempting to call an API using this client/account packages for example it simply returned no cached connection available when $env:GODEBUG='http2debug=1' is set, when its not it just returns an EOF most likely because of the reuse of the connection that's not there. The Octopus server is running TLS and at 1.2. The api calls work via web browser / PowerShell.

Steps To Reproduce Provide a detailed list of steps that reproduce the issue.

package main

import (
	"fmt"
	"net/url"

	"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
	"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
)

func GetAccountByIDExample() {
	var (
		apiKey     string = "<APIKEY>"
		octopusURL string = "https://<FQDN>/Octopus"
		spaceID    string = "Default"

		// account values
		accountID string = "<USERID>"
	)

	apiURL, err := url.Parse(octopusURL)
	if err != nil {
		_ = fmt.Errorf("error parsing URL for Octopus API: %v", err)
		return
	}

	octopusClient, err := client.NewClient(nil, apiURL, apiKey, "")
	if err != nil {
		_ = fmt.Errorf("error creating API client: %v", err)
		return
	}

	// get account by its ID
	account, err := accounts.GetByID(octopusClient, spaceID, accountID)
	if err != nil {
		_ = fmt.Errorf("error getting account: %v", err)
		return
	}

	fmt.Printf("account: (%s)\n", account.GetID())
}
func main() {
	GetAccountByIDExample()
}

Expected Behavior It should establish a client connection to Octopus and query the accounts with query id. It should just return the same value as provided in the vars via std out.

Any Logs and/or Other Supporting Information

Environment and/or Versions

  • Octopus Server Version: [2024.2.9313]
  • go version go1.23.2 windows/amd64

Additional Context Add any other context about the problem here.

conradj3 avatar Jan 04 '25 02:01 conradj3