Skip to content

Commit

Permalink
Merge pull request #186 from jumpserver/pr@dev@record_session_life
Browse files Browse the repository at this point in the history
fix: keal会话生命周期优化
  • Loading branch information
feng626 authored May 15, 2024
2 parents ab71eb0 + fd406db commit d52652d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/httpd/router/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *_ChatApi) ChatHandler(ctx *gin.Context) {
if err != nil {
if len(currentJMSS) != 0 {
for _, jmss := range currentJMSS {
jmss.Close("Websocket已关闭, 会话中断")
jmss.Close("Websocket已关闭 会话中断")
}
}
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/httpd/router/system_chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *_SystemChatApi) ChatHandler(ctx *gin.Context) {
if err != nil {
if len(currentJMSS) != 0 {
for _, jmss := range currentJMSS {
jmss.Close("Websocket已关闭, 会话中断")
jmss.Close("Websocket已关闭 会话中断")
}
}
return
Expand Down
6 changes: 3 additions & 3 deletions pkg/jms/jms_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (jmss *JMSSession) MaximumIdleTimeDetection() {
idleTime := currentTime.Sub(lastActiveTime)

if idleTime.Seconds() >= float64(jmss.MaxIdleTime*60) {
reason := fmt.Sprintf("超过当前会话最大空闲时间 %d (分), 会话中断", jmss.MaxIdleTime)
reason := fmt.Sprintf("超过当前会话最大空闲时间 %d (分) 会话中断", jmss.MaxIdleTime)
jmss.Close(reason)
break
}
Expand All @@ -74,7 +74,7 @@ func (jmss *JMSSession) MaxSessionTimeDetection() {
idleTime := currentTime.Sub(lastActiveTime)

if idleTime.Seconds() >= float64(jmss.MaxSessionTime*60*60) {
reason := fmt.Sprintf("超过当前会话最大时间 %d (时), 会话中断", jmss.MaxSessionTime)
reason := fmt.Sprintf("超过当前会话最大时间 %d (时) 会话中断", jmss.MaxSessionTime)
jmss.Close(reason)
break
}
Expand All @@ -87,7 +87,7 @@ func (jmss *JMSSession) Close(reason string) {
go jmss.SessionHandler.recordSessionLife(
jmss.Session,
protobuf.SessionLifecycleLogRequest_AssetConnectFinished,
"",
reason,
)
time.Sleep(1 * time.Second)
jmss.ReplayHandler.Upload()
Expand Down

0 comments on commit d52652d

Please sign in to comment.