Skip to content

Commit

Permalink
fixing grpc header issue on response.
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlavanet committed Jun 3, 2024
1 parent b37d044 commit 1a6fae8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion protocol/chainlib/grpcproxy/grpcproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grpcproxy
import (
"context"
"net/http"
"strings"

"github.com/gofiber/fiber/v2"
"github.com/improbable-eng/grpc-web/go/grpcweb"
Expand Down Expand Up @@ -79,7 +80,18 @@ func makeProxyFunc(callBack ProxyCallBack) grpc.StreamHandler {
if err != nil {
return err
}
stream.SetHeader(md)

// Convert metadata keys to lowercase
lowercaseMD := metadata.New(map[string]string{})
for k, v := range md {
lowerKey := strings.ToLower(k)
lowercaseMD[lowerKey] = v
}
md = lowercaseMD

if err := stream.SetHeader(md); err != nil {
utils.LavaFormatError("Got error when setting header", err, utils.LogAttr("headers", md))
}
return stream.SendMsg(respBytes)
}
}
Expand Down
2 changes: 2 additions & 0 deletions protocol/statetracker/consumer_state_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package statetracker

import (
"context"
"time"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
Expand Down Expand Up @@ -69,6 +70,7 @@ func (cst *ConsumerStateTracker) RegisterConsumerSessionManagerForPairingUpdates
numberOfAttempts := 0
for {
utils.LavaFormatError("Failed retry RegisterPairing", err, utils.LogAttr("attempt", numberOfAttempts), utils.Attribute{Key: "data", Value: consumerSessionManager.RPCEndpoint()})
time.Sleep(5 * time.Second) // sleep so we don't spam get pairing for no reason
err := pairingUpdater.RegisterPairing(ctx, consumerSessionManager)
if err == nil {
break
Expand Down

0 comments on commit 1a6fae8

Please sign in to comment.