diff --git a/conn/channel.go b/conn/channel.go index f42398d8..b9a7bdfd 100644 --- a/conn/channel.go +++ b/conn/channel.go @@ -382,10 +382,10 @@ func DialChannelWithClient(endpoint string, config *tls.Config, groupID int) (*C if err = ch.handshakeChannel(); err != nil { logrus.Errorf("handshake channel protocol failed, use default protocol version") } - // ch.topicHandlers[blockNotifyPrefix+strconv.Itoa(groupID)] = nil - // if err = ch.sendSubscribedTopics(); err != nil { - // return nil, fmt.Errorf("subscriber block nofity failed") - // } + ch.topicHandlers[blockNotifyPrefix+strconv.Itoa(groupID)] = nil + if err = ch.sendSubscribedTopics(); err != nil { + return nil, fmt.Errorf("subscriber block nofity failed") + } return ch, nil }) } @@ -752,7 +752,7 @@ func (hc *channelSession) subscribeTopic(topic string, handler func([]byte, *[]b if handler == nil { return errors.New("handler is nil") } - if _, ok := hc.topicHandlers[topic]; ok { + if oldHandler, ok := hc.topicHandlers[topic]; ok && oldHandler != nil { return errors.New("already subscribed to topic " + topic) } hc.topicMu.Lock()