diff --git a/grpc.go b/grpc.go index b039c02..d8a1cb8 100644 --- a/grpc.go +++ b/grpc.go @@ -752,16 +752,19 @@ func (g *grpcServer) Start() error { g.opts.Address = ts.Addr().String() g.Unlock() - // connect to the broker - if err := config.Broker.Connect(); err != nil { - return err + // only connect if we're subscribed + if len(g.subscribers) > 0 { + // connect to the broker + if err := config.Broker.Connect(); err != nil { + return err + } + + baddr := config.Broker.Address() + bname := config.Broker.String() + + log.Logf("Broker [%s] Connected to %s", bname, baddr) } - baddr := config.Broker.Address() - bname := config.Broker.String() - - log.Logf("Broker [%s] Connected to %s", bname, baddr) - // announce self to the world if err := g.Register(); err != nil { log.Log("Server register error: ", err)