Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip empty message #2352

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions node/pkg/wss/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@ func (ws *WebsocketHelper) Run(ctx context.Context, router func(context.Context,
log.Error().Err(err).Str("endpoint", ws.Endpoint).Msg("error reading from websocket")
break innerLoop
}

ws.lastMessageTime = time.Now()

go func(context.Context, map[string]any) {
routerErr := router(ctx, data)
if routerErr != nil {
log.Warn().Err(routerErr).Str("endpoint", ws.Endpoint).Msg("error processing websocket message")
}
}(ctx, data)
if len(data) != 0 {
go func(context.Context, map[string]any) {
routerErr := router(ctx, data)
if routerErr != nil {
log.Warn().Err(routerErr).Str("endpoint", ws.Endpoint).Msg("error processing websocket message")
}
}(ctx, data)
}
}
}
ws.Close()
Expand Down Expand Up @@ -228,5 +231,10 @@ func defaultReader(ctx context.Context, conn *websocket.Conn) (map[string]interf
if err != nil {
return nil, err
}

if len(data) == 0 {
return nil, nil
}

return data, nil
}
Loading