From ec43b208a2d7dc00c39771925f8333e45935816d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 30 Nov 2022 19:05:10 +0800 Subject: [PATCH] fix: connection timeout (#376) (#381) Co-authored-by: Xiaolong Lu --- server/api/studio/pkg/auth/authorize.go | 6 +++++- server/go.mod | 2 +- server/go.sum | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/api/studio/pkg/auth/authorize.go b/server/api/studio/pkg/auth/authorize.go index 55ba6815..b5ef3c62 100644 --- a/server/api/studio/pkg/auth/authorize.go +++ b/server/api/studio/pkg/auth/authorize.go @@ -11,6 +11,7 @@ import ( "time" "github.com/golang-jwt/jwt/v4" + "github.com/vesoft-inc/nebula-http-gateway/ccore/nebula" "github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/dao" "github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/pool" "github.com/vesoft-inc/nebula-studio/server/api/studio/internal/config" @@ -38,6 +39,8 @@ type ( } ) +var GraphServiceConnectTimeout = 5 * time.Second + func CreateToken(authData *AuthData, config *config.Config) (string, error) { now := time.Now() expiresAt := now.Add(time.Duration(config.Auth.AccessExpire) * time.Second).Unix() @@ -105,7 +108,8 @@ func ParseConnectDBParams(params *types.ConnectDBParams, config *config.Config) } username, password := loginInfo[0], loginInfo[1] - clientInfo, err := dao.Connect(params.Address, params.Port, username, password) + // set Graph Service connect timeout 5s, which is 0s default(means no timeout) + clientInfo, err := dao.Connect(params.Address, params.Port, username, password, nebula.WithGraphTimeout(GraphServiceConnectTimeout)) if err != nil { return "", nil, err } diff --git a/server/go.mod b/server/go.mod index fc56e2f1..f7cd497f 100644 --- a/server/go.mod +++ b/server/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/samber/lo v1.28.2 github.com/vesoft-inc/go-pkg v0.0.0-20220714021138-c5edb9946837 - github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221114094653-748b8f063bb6 + github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221130062253-8ae8bd95d139 github.com/vesoft-inc/nebula-importer v1.0.1-0.20220719030708-8e376665042e github.com/zeromicro/go-zero v1.3.3 ) diff --git a/server/go.sum b/server/go.sum index 2aaf9bbf..042efab5 100644 --- a/server/go.sum +++ b/server/go.sum @@ -404,8 +404,8 @@ github.com/vesoft-inc/go-pkg v0.0.0-20220714021138-c5edb9946837/go.mod h1:HCAXRh github.com/vesoft-inc/nebula-go/v3 v3.0.0-20220425030225-cdb52399b40a/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s= github.com/vesoft-inc/nebula-go/v3 v3.2.0 h1:f0IW6W5f91O6FyXAi+kFq1D2bNFXtPtkb/H9WywFGmM= github.com/vesoft-inc/nebula-go/v3 v3.2.0/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s= -github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221114094653-748b8f063bb6 h1:y4H+PmtU9JnmFw7KmaFb3Ha8B2EuG2HdQnoG0RbcKNo= -github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221114094653-748b8f063bb6/go.mod h1:sFEvE+cY4TgwqWx6H6msOqAUzRhsEHHKaaMgIZENHuQ= +github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221130062253-8ae8bd95d139 h1:wzIe4IyCZ4+BwM2F4wdJoERxjZf4/pVLJcMhMqgaRys= +github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221130062253-8ae8bd95d139/go.mod h1:sFEvE+cY4TgwqWx6H6msOqAUzRhsEHHKaaMgIZENHuQ= github.com/vesoft-inc/nebula-importer v1.0.1-0.20220719030708-8e376665042e h1:Xj3N5lfKv+mG59Fh2GoWZ/89kWEwQtW/W4EiKkD2yI0= github.com/vesoft-inc/nebula-importer v1.0.1-0.20220719030708-8e376665042e/go.mod h1:8xAQi6KI2qe40Dop/GqDXmBEurt7qGp5Pjd1MESAVNA= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=