Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 401 with concurrent requests #43

Open
jon4hz opened this issue Jul 24, 2023 · 0 comments
Open

Error 401 with concurrent requests #43

jon4hz opened this issue Jul 24, 2023 · 0 comments

Comments

@jon4hz
Copy link

jon4hz commented Jul 24, 2023

When I tried to use this library with concurrent api calls, I sometimes get an error 401.

url, user, password := "http://www.example.com/secrets", "robpike", "pw123"
client := &http.Client{
  Transport: ntlmssp.Negotiator{
    RoundTripper:&http.Transport{},
  },
}
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
  wg.Add(1)
  go func() {
    defer wg.Done()
    req, _ := http.NewRequest("GET", url, nil)
    req.SetBasicAuth(user, password)
    res, _ := client.Do(req)
    fmt.Println(resp.StatusCode)
  }()
}
wg.Wait()

If I make sure that the client only uses 1 active connection, I don't get any error. So I'm guessing this is a bug, right?

client := &http.Client{
  Transport: ntlmssp.Negotiator{
    RoundTripper:&http.Transport{
      MaxConnsPerHost: 1,  // limit connections
    },
  },
}
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

No branches or pull requests

1 participant