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

Maximum number of clients reached #40

Open
co60ca opened this issue Sep 10, 2017 · 3 comments
Open

Maximum number of clients reached #40

co60ca opened this issue Sep 10, 2017 · 3 comments

Comments

@co60ca
Copy link

co60ca commented Sep 10, 2017

If you open over 200 connections and close them you will get this error:

x protocol authentication refused: Maximum number of clients reached

func TestXGB (t *testing.T) {                                                   
  for i := 0; i < 1000; i++ {                                                   
    t.Log("log", i, '/', 1000)                                                  
    c, err := xgb.NewConn()                                                     
    if err != nil {                                                             
      t.Fatal("Bad things happened", err)                                       
    }                                                                           
    defer c.Close()                                                             
  }                                                                             
}

This seems to be valid application so I'm not sure what is going wrong here.

@BurntSushi
Copy link
Owner

BurntSushi commented Sep 10, 2017 via email

@co60ca
Copy link
Author

co60ca commented Sep 10, 2017

To be more clear, we are closing the connection each time, only one should be active.

func TestXGB (t *testing.T) {                                                   
  for i := 0; i < 1000; i++ {                                                   
    t.Log("log", i, '/', 1000)                                                  
    c, err := xgb.NewConn()                                                     
    if err != nil {                                                             
      t.Fatal("Bad things happened", err)                                       
    }                                                                           
    c.Close()                                                                   
  }                                                                             
}   

Rewrote and tested without defer to be more clear. Closing the connection should free resources correct? So creating and closing the connection 200+ times shouldn't have a resource leak.

I'm trying to help assist in fixing a bug in someone else's project utilizing this codebase. See:
https://github.com/vova616/screenshot

I wrote a workaround for their library but I would like to assist in fixing it here as well.

To be clear, creating 250 connections in less than a second isn't my use case, but shows the issue.

Also I misunderstood how defer worked so there might have been an error in the original test case, however it shows the same result before and after, furthering my point.

@BurntSushi
Copy link
Owner

Right, the original test case did indeed open many connections simultaneously since defer applies to the scope of the enclosing function.

Your second test case it's more interesting and I agree it should work. I still think it's a little odd to be opening and closing connections instead of keeping one open, but you'll have to dig into this to figure out the problem. IIRC, someone had reported this issue before, so you might have luck looking at past issues.

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

2 participants