diff --git a/README.md b/README.md index ebf490f59a5ab4ac6c8a154785443cff0ed28310..cea5fab8b9a8747cdba27356d70d8187ed49de7f 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ Flags: (default 1) --sendDelay uint The delay between sending the messages in ms (default 500) - --sendid uint Use precanned user id (must be between 1 and + --sendid uiverboseRoundTrackingnt Use precanned user id (must be between 1 and 40, inclusive) --slowPolling bool Enables polling for all network updates and RSA signed rounds. Defaults to true (filtered updates with ECC signed rounds) if not set @@ -190,6 +190,9 @@ Flags: --unsafe-channel-creation Turns off the user identity authenticated channel check, automatically approving authenticated channels + --verboseRoundTracking Verbose round tracking, keeps track and prints + all rounds the client was aware of while running. + Defaults to false if not set. -v, --logLevel uint Level of debugging to print (0 = info, 1 = debug, >1 = trace). (Default info) --waitTimeout uint The number of seconds to wait for messages to diff --git a/cmd/root.go b/cmd/root.go index b70abd225cc83fd59e8f64af0822aa747c2875af..a8d4f600ae9470aa3f7eddae63001ac390ca8665 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -247,7 +247,10 @@ var rootCmd = &cobra.Command{ } } fmt.Printf("Received %d\n", receiveCnt) - roundsNotepad.INFO.Printf("\n%s", client.GetNetworkInterface().GetVerboseRounds()) + if roundsNotepad!=nil{ + roundsNotepad.INFO.Printf("\n%s", client.GetNetworkInterface().GetVerboseRounds()) + } + err = client.StopNetworkFollower() if err != nil { jww.WARN.Printf( @@ -384,7 +387,7 @@ func createClient() *api.Client { netParams.ForceHistoricalRounds = viper.GetBool("forceHistoricalRounds") netParams.FastPolling = !viper.GetBool("slowPolling") netParams.ForceMessagePickupRetry = viper.GetBool("forceMessagePickupRetry") - netParams.VerboseRoundTracking = logLevel > 0 + netParams.VerboseRoundTracking = viper.GetBool("verboseRoundTracking") client, err := api.OpenClient(storeDir, []byte(pass), netParams) if err != nil { @@ -412,7 +415,7 @@ func initClient() *api.Client { jww.INFO.Printf("Setting Uncheck Round Period to %v", period) netParams.UncheckRoundPeriod = period } - netParams.VerboseRoundTracking = viper.GetUint("logLevel") > 0 + netParams.VerboseRoundTracking = viper.GetBool("verboseRoundTracking") //load the client client, err := api.Login(storeDir, []byte(pass), netParams) @@ -729,6 +732,11 @@ func init() { "Verbose mode for debugging") viper.BindPFlag("logLevel", rootCmd.PersistentFlags().Lookup("logLevel")) + rootCmd.PersistentFlags().Bool("verboseRoundTracking", false, + "Verbose round tracking, keeps track and prints all rounds the " + + "client was aware of while running. Defaults to false if not set.") + viper.BindPFlag("verboseRoundTracking", rootCmd.PersistentFlags().Lookup("verboseRoundTracking")) + rootCmd.PersistentFlags().StringP("session", "s", "", "Sets the initial storage directory for "+ "client session data") diff --git a/go.mod b/go.mod index 18f312d704c9b102549cae8c0170f91432e5de57..fbb8fe232e15c1375a4449bd18d4ae417b75e1da 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/viper v1.7.1 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 - gitlab.com/elixxir/comms v0.0.4-0.20210921011907-2be8c9faa4d8 + gitlab.com/elixxir/comms v0.0.4-0.20210923193811-eff1796c4f06 gitlab.com/elixxir/crypto v0.0.7-0.20210920180151-6c9b84bae372 gitlab.com/elixxir/ekv v0.1.5 gitlab.com/elixxir/primitives v0.0.3-0.20210920180121-b85bca5212f4 diff --git a/go.sum b/go.sum index 238ea4e16aaee9b1d3a428a4641f8f71aef19154..663d0aca4f036337fcbd3f3c7a886918191eb612 100644 --- a/go.sum +++ b/go.sum @@ -253,8 +253,8 @@ github.com/zeebo/pcg v1.0.0 h1:dt+dx+HvX8g7Un32rY9XWoYnd0NmKmrIzpHF7qiTDj0= github.com/zeebo/pcg v1.0.0/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 h1:Gi6rj4mAlK0BJIk1HIzBVMjWNjIUfstrsXC2VqLYPcA= gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k= -gitlab.com/elixxir/comms v0.0.4-0.20210921011907-2be8c9faa4d8 h1:MqVGu0ADBHMw7rfiSJTG4PRlGk8c8N6GLY1CwJwC3Dk= -gitlab.com/elixxir/comms v0.0.4-0.20210921011907-2be8c9faa4d8/go.mod h1:h41+FHc9zlQGveEao3aw8VSfzyOPecEhhUIadUsW1C8= +gitlab.com/elixxir/comms v0.0.4-0.20210923193811-eff1796c4f06 h1:/eravscU36XKXmGdPfDTNNNgjc1eEhsRwwbir43SS64= +gitlab.com/elixxir/comms v0.0.4-0.20210923193811-eff1796c4f06/go.mod h1:h41+FHc9zlQGveEao3aw8VSfzyOPecEhhUIadUsW1C8= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA= gitlab.com/elixxir/crypto v0.0.7-0.20210920180151-6c9b84bae372 h1:W5Ax+cwqOOcsVegaMLvsFJ/Cs24a4Wyhp5UHFwvMQxo= diff --git a/network/gateway/sender.go b/network/gateway/sender.go index 1ae30ccea55592574e0aa9813c0b2af6ed185d55..693fdf058130465048d00371b3c5c23dabb1a150 100644 --- a/network/gateway/sender.go +++ b/network/gateway/sender.go @@ -26,6 +26,8 @@ type Sender struct { *HostPool } +const RetryableError = "Nonfatal error occurred, please retry" + // NewSender Create a new Sender object wrapping a HostPool object func NewSender(poolParams PoolParams, rng *fastRNG.StreamGenerator, ndf *ndf.NetworkDefinition, getter HostManager, storage *storage.Session, addGateway chan network.NodeGateway) (*Sender, error) { @@ -47,10 +49,12 @@ func (s *Sender) SendToAny(sendFunc func(host *connect.Host) (interface{}, error return nil, errors.Errorf(stoppable.ErrMsg, stop.Name(), "SendToAny") }else if err==nil{ return result, nil - } else if strings.Contains(err.Error(),"unable to connect to target host") { + } else if strings.Contains(err.Error(), RetryableError) { // Retry of the proxy could not communicate - jww.WARN.Printf("Unable to SendToAny via %s: proxy could not contact requested host: %s", + jww.INFO.Printf("Unable to SendToAny via %s: non-fatal error received, retrying: %s", proxies[proxy].GetId().String(), err) + }else if strings.Contains(err.Error(),"unable to connect to target host") { + }else if replaced, checkReplaceErr := s.checkReplace(proxies[proxy].GetId(), err); replaced{ if checkReplaceErr!=nil{ jww.WARN.Printf("Unable to SendToAny, replaced a proxy %s with error %s", @@ -82,7 +86,11 @@ func (s *Sender) SendToPreferred(targets []*id.ID, return nil, errors.Errorf(stoppable.ErrMsg, stop.Name(), "SendToPreferred") } else if err == nil { return result, nil - } else if strings.Contains(err.Error(),"unable to connect to target host") { + } else if strings.Contains(err.Error(), RetryableError) { + // Retry of the proxy could not communicate + jww.INFO.Printf("Unable to to SendToPreferred first pass %s via %s: non-fatal error received, retrying: %s", + targets[i], targetHosts[i].GetId(), err) + }else if strings.Contains(err.Error(),"unable to connect to target host") { // Retry of the proxy could not communicate jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s: %s, " + "proxy could not contact requested host", @@ -141,7 +149,11 @@ func (s *Sender) SendToPreferred(targets []*id.ID, return nil, errors.Errorf(stoppable.ErrMsg, stop.Name(), "SendToPreferred") } else if err == nil { return result, nil - } else if strings.Contains(err.Error(),"unable to connect to target host") { + } else if strings.Contains(err.Error(), RetryableError) { + // Retry of the proxy could not communicate + jww.INFO.Printf("Unable to SendToPreferred second pass %s via %s: non-fatal error received, retrying: %s", + target, proxy, err) + }else if strings.Contains(err.Error(),"unable to connect to target host") { // Retry of the proxy could not communicate jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s: %s," + " proxy could not contact requested host", diff --git a/network/manager.go b/network/manager.go index f47191c0bdb39add026c8ff11ee7b7b946368975..5a4fbc76b0d08619a2b07afd16ed3f5d46838cd1 100644 --- a/network/manager.go +++ b/network/manager.go @@ -107,6 +107,9 @@ func NewManager(session *storage.Session, switchboard *switchboard.Switchboard, Events: events, } + // Set up node registration chan for network instance + m.Instance.SetAddGatewayChan(m.NodeRegistration) + // Set up gateway.Sender poolParams := gateway.DefaultPoolParams() // Client will not send KeepAlive packets diff --git a/network/rounds/retrieve.go b/network/rounds/retrieve.go index bd7f1d682760d2f0160e2b9c4f9ca32f749bc534..cf1584a8d753b063e9b128dfcb15848ac5080bc0 100644 --- a/network/rounds/retrieve.go +++ b/network/rounds/retrieve.go @@ -11,6 +11,7 @@ import ( "encoding/binary" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/client/network/gateway" "gitlab.com/elixxir/client/network/message" "gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/storage/reception" @@ -157,8 +158,8 @@ func (m *Manager) getMessagesFromGateway(roundID id.Round, // If the gateway doesnt have the round, return an error msgResp, err := comms.RequestMessages(host, msgReq) if err == nil && !msgResp.GetHasRound() { - jww.INFO.Printf("No round error for round %d received from %s", roundID, target) - return message.Bundle{}, errors.Errorf(noRoundError, roundID) + errRtn := errors.Errorf(noRoundError, roundID) + return message.Bundle{}, errors.WithMessage(errRtn,gateway.RetryableError) } return msgResp, err