Skip to content

Commit

Permalink
Merge pull request #738 from mesg-foundation/fix/server-keepalive
Browse files Browse the repository at this point in the history
Add 1 min keepalive in grpc
  • Loading branch information
ilgooz authored Jan 28, 2019
2 parents 81de995 + 822b22c commit f5d74bc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions interface/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grpc
import (
"net"
"sync"
"time"

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/mesg-foundation/core/protobuf/serviceapi"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/reflection"
)

Expand Down Expand Up @@ -51,7 +53,11 @@ func (s *Server) listen() (net.Listener, error) {
return nil, err
}

keepaliveOpt := grpc.KeepaliveParams(keepalive.ServerParameters{
Time: 1 * time.Minute,
})
s.instance = grpc.NewServer(
keepaliveOpt,
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
grpc_logrus.StreamServerInterceptor(logrus.NewEntry(logrus.StandardLogger())),
)),
Expand Down

0 comments on commit f5d74bc

Please sign in to comment.