fix: unreliable websocket functionality (#144)

* increases timeout

* refactor: reuse constants for redis db

* avoid closing connection on pong error

* fix: prevent electron from pausing timer executions

Our pings could be paused when our app is backgrounded.

* refactor: remove unnecessary refs

* fix: presence unreliable within same pod

It was broadcasting presence changes to other pods, but not notifying
clients connected to the same pod
This commit was merged in pull request #144.
This commit is contained in:
Arjun Patel
2026-04-12 10:00:11 -07:00
committed by GitHub
parent 4cb562e1ea
commit 2bc4ce7060
11 changed files with 64 additions and 35 deletions
+1 -6
View File
@@ -27,13 +27,8 @@ import (
"google.golang.org/grpc/credentials/insecure"
)
const (
// FIX: Use separate redis instance. We start with higher number because use this same instance in helios.
REDIS_DATABASE_FOR_AUTH int = 4
)
func redisForAuth() *redis.Client {
return internal.ConnectAndTestRedis(REDIS_DATABASE_FOR_AUTH)
return internal.ConnectAndTestRedis(db.RedisDBAuth)
}
func main() {
+7 -12
View File
@@ -21,11 +21,6 @@ import (
"google.golang.org/grpc"
)
const (
redisDBAuth = 4 // shared with orion for session validation
redisDBPusher = 5 // dedicated to pusher state (presence, pub/sub)
)
func main() {
port := utils.MustGetEnv("PORT")
grpcPort := utils.MustGetEnv("GRPC_PORT")
@@ -35,10 +30,10 @@ func main() {
defer db.Cleanup()
// Redis for auth session validation (same DB as orion)
authRedis := internal.ConnectAndTestRedis(redisDBAuth)
authRedis := internal.ConnectAndTestRedis(db.RedisDBAuth)
// Redis for pusher state (presence hashes, pub/sub)
pusherRedis := internal.ConnectAndTestRedis(redisDBPusher)
pusherRedis := internal.ConnectAndTestRedis(db.RedisDBPusher)
// Services
authSvc := auth.NewAuthService(authRedis, nil) // nil aeroSvc — pusher only calls GetSession
@@ -52,15 +47,15 @@ func main() {
// Pusher core
bridge := pusher.NewRedisBridge(pusherRedis, podID)
authorizer := pusher.NewAuthorizer(networkSvc)
hub := pusher.NewHub(bridge, authorizer)
bridge.SetHub(hub)
server := pusher.NewServer(hub, bridge, authSvc)
// Context for graceful shutdown
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
authorizer := pusher.NewAuthorizer(networkSvc)
hub := pusher.NewHub(bridge, authorizer)
bridge.SetHub(hub)
server := pusher.NewServer(ctx, hub, bridge, authSvc)
// Start hub event loop
go hub.Run(ctx)