@@ -322,6 +322,28 @@ func (l *Line) listDevicesFromURL(mobiusURL string) ([]MobiusDevice, error) {
322322 return []MobiusDevice {}, nil
323323 }
324324
325+ // 503 means stale registrations blocking new ones — try to parse device info
326+ if resp .StatusCode == http .StatusServiceUnavailable {
327+ log .Printf ("ListDevices: got 503 (stale registrations), response: %s" , string (body ))
328+ var errResp struct {
329+ Devices []MobiusDevice `json:"devices"`
330+ }
331+ if json .Unmarshal (body , & errResp ) == nil {
332+ var validDevices []MobiusDevice
333+ for _ , d := range errResp .Devices {
334+ if d .DeviceID != "" {
335+ validDevices = append (validDevices , d )
336+ }
337+ }
338+ if len (validDevices ) > 0 {
339+ return validDevices , nil
340+ }
341+ }
342+ // Mobius returned 503 with null devices — no IDs to delete.
343+ // Stale registrations will auto-expire in ~3-5 minutes.
344+ return nil , fmt .Errorf ("503: stale registrations exist but Mobius returned no device IDs; wait a few minutes for auto-expiry" )
345+ }
346+
325347 return nil , fmt .Errorf ("unexpected status %d: %s" , resp .StatusCode , string (body ))
326348}
327349
@@ -396,10 +418,6 @@ func (l *Line) onRegistered() {
396418// Deregister deregisters this line from the Mobius server
397419func (l * Line ) Deregister () error {
398420 l .mu .RLock ()
399- if l .status != RegistrationStatusActive {
400- l .mu .RUnlock ()
401- return nil
402- }
403421 mobiusURL := l .activeMobiusURL
404422 deviceID := l .MobiusDeviceID
405423 l .mu .RUnlock ()
0 commit comments