code: func (s *Service) connect(fail chan struct{}) (*Client, bool) {
  	// prepare new client
  	client := New()
  	client.Session = s.Session
  	client.Logger = s.Logger
  	client.futureStore = s.futureStore
  
  	// set callback
  	client.Callback = func(msg *packet.Message, err error) error {
  		if err != nil {
  			s.err("Client", err)
  			close(fail)
  			return nil
  		}
  
  		// call the handler
  		if s.MessageCallback != nil {
  			return s.MessageCallback(msg)
  		}
  
  		return nil
  	}
  
  	// attempt to connect
  	connectFuture, err := client.Connect(s.config)
  	if err != nil {
  		s.err("Connect", err)
  		return nil, false
  	}
  
  	// wait for connack
  	err = connectFuture.Wait(s.ConnectTimeout)
  
  	// check if future has been canceled
  	if err == future.ErrCanceled {
  		s.err("Connect", err)
  		return nil, false
  	}
  
  	// check if future has timed out
  	if err == future.ErrTimeout {
  		client.Close()
  
  		s.err("Connect", err)
  		return nil, false
  	}
  
  	return client, connectFuture.SessionPresent()
  }
docs: // will try to connect one client to the broker