Only register broadcast receivers after a successful ws:// upgrade
@@ -787,6 +787,11 @@ func (core *Core) v2API() *route.Router {
return
}
+ socket := r.Upgrade()
+ if socket == nil {
+ return
+ }
+
log.Infof("registering broadcast receiver")
in := make(chan Event)
id, err := core.broadcast.Register(in)
@@ -795,11 +800,6 @@ func (core *Core) v2API() *route.Router {
return
}
- socket := r.Upgrade()
- if socket == nil {
- return
- }
-
go socket.Discard()
for event := range in {
if event.Task != nil && event.Task.TenantUUID.String() == r.Args[1] && event.Task.TargetUUID.String() == r.Args[2] {
