diff --git a/server/channel_broker.go b/server/channel_broker.go index de70b4d7..89d09f00 100644 --- a/server/channel_broker.go +++ b/server/channel_broker.go @@ -93,6 +93,9 @@ outer: select { case <-ctx.Done(): // todo(fs): return error? + if c.logger != nil { + c.logger.Warn("Context done, closing Secure Channel %d", secureChannelID) + } break outer default: @@ -102,6 +105,11 @@ outer: c.logger.Warn("Secure Channel %d closed", secureChannelID) } break outer + } else if msg.Err != nil { + if c.logger != nil { + c.logger.Error("Secure Channel %d error: %s", secureChannelID, msg.Err) + } + break outer } // todo(fs): honor ctx c.msgChan <- msg diff --git a/server/monitored_item_service.go b/server/monitored_item_service.go index 2a32b95f..a561148c 100644 --- a/server/monitored_item_service.go +++ b/server/monitored_item_service.go @@ -85,6 +85,7 @@ func (s *MonitoredItemService) DeleteMonitoredItem(id uint32) { func (s *MonitoredItemService) DeleteSub(id uint32) { s.Mu.Lock() items, ok := s.Subs[id] + delete(s.Subs, id) s.Mu.Unlock() if !ok { return diff --git a/server/subscription_service.go b/server/subscription_service.go index c5981f65..bb3c65e0 100644 --- a/server/subscription_service.go +++ b/server/subscription_service.go @@ -55,7 +55,7 @@ func (s *SubscriptionService) CreateSubscription(sc *uasc.SecureChannel, r ua.Re s.Mu.Lock() defer s.Mu.Unlock() - newsubid := uint32(len(s.Subs)) + newsubid := uint32(len(s.Subs)) + 1 if s.srv.cfg.logger != nil { s.srv.cfg.logger.Info("New Sub %d for %v", newsubid, sc.RemoteAddr())