diff --git a/protocol/lavasession/common.go b/protocol/lavasession/common.go index 00bd892fca..add8cdcccb 100644 --- a/protocol/lavasession/common.go +++ b/protocol/lavasession/common.go @@ -25,8 +25,8 @@ import ( const ( MaxConsecutiveConnectionAttempts = 5 - TimeoutForEstablishingAConnection = 1 * time.Second - MaxSessionsAllowedPerProvider = 1000 // Max number of sessions allowed per provider + TimeoutForEstablishingAConnection = 1500 * time.Millisecond // 1.5 seconds + MaxSessionsAllowedPerProvider = 1000 // Max number of sessions allowed per provider MaxAllowedBlockListedSessionPerProvider = 3 MaximumNumberOfFailuresAllowedPerConsumerSession = 3 RelayNumberIncrement = 1 diff --git a/protocol/rpcconsumer/rpcconsumer_server.go b/protocol/rpcconsumer/rpcconsumer_server.go index c00679a531..0799e93c5c 100644 --- a/protocol/rpcconsumer/rpcconsumer_server.go +++ b/protocol/rpcconsumer/rpcconsumer_server.go @@ -31,6 +31,7 @@ import ( const ( MaxRelayRetries = 6 + SendRelayAttempts = 3 numberOfTimesToCheckCurrentlyUsedIsEmpty = 3 ) @@ -329,10 +330,15 @@ func (rpccs *RPCConsumerServer) ProcessRelaySend(ctx context.Context, directiveH ctx, cancel := context.WithCancel(ctx) defer cancel() relayProcessor := NewRelayProcessor(ctx, lavasession.NewUsedProviders(directiveHeaders), rpccs.requiredResponses, chainMessage, rpccs.consumerConsistency, dappID, consumerIp) - err := rpccs.sendRelayToProvider(ctx, chainMessage, relayRequestData, dappID, consumerIp, relayProcessor) - if err != nil && relayProcessor.usedProviders.CurrentlyUsed() == 0 { - // we failed to send a batch of relays, if there are no active sends we can terminate - return relayProcessor, err + var err error + // try sending a relay 3 times. if failed return the error + for retryFirstRelayAttempt := 0; retryFirstRelayAttempt < SendRelayAttempts; retryFirstRelayAttempt++ { + err = rpccs.sendRelayToProvider(ctx, chainMessage, relayRequestData, dappID, consumerIp, relayProcessor) + // check if we had an error. if we did, try again. + if err == nil { + break + } + utils.LavaFormatWarning("Failed retryFirstRelayAttempt, will retry.", err, utils.LogAttr("attempt", retryFirstRelayAttempt)) } // a channel to be notified processing was done, true means we have results and can return gotResults := make(chan bool)