改进在自动读超时模式下的Websocket连接

This commit is contained in:
刘祥超
2023-01-09 12:36:33 +08:00
parent a2e6aaaa18
commit 2d4ba90c3b
4 changed files with 24 additions and 3 deletions

View File

@@ -94,7 +94,7 @@ func (this *ClientConn) Read(b []byte) (n int, err error) {
// 设置读超时时间
var autoReadTimeout = globalServerConfig != nil && globalServerConfig.Performance.AutoReadTimeout
if this.isHTTP && !this.isShortReading && autoReadTimeout {
if this.isHTTP && !this.isWebsocket && !this.isShortReading && autoReadTimeout {
this.setHTTPReadTimeout()
}
@@ -157,7 +157,7 @@ func (this *ClientConn) Write(b []byte) (n int, err error) {
}
// 延长读超时时间
if this.isHTTP {
if this.isHTTP && !this.isWebsocket && globalServerConfig != nil && globalServerConfig.Performance.AutoReadTimeout {
this.setHTTPReadTimeout()
}
@@ -217,7 +217,7 @@ func (this *ClientConn) SetDeadline(t time.Time) error {
func (this *ClientConn) SetReadDeadline(t time.Time) error {
// 如果开启了HTTP自动读超时选项则自动控制超时时间
var globalServerConfig = sharedNodeConfig.GlobalServerConfig
if this.isHTTP && globalServerConfig != nil && globalServerConfig.Performance.AutoReadTimeout {
if this.isHTTP && !this.isWebsocket && globalServerConfig != nil && globalServerConfig.Performance.AutoReadTimeout {
this.isShortReading = false
var unixTime = t.Unix()