ohmae / mmupnp

Universal Plug and Play (UPnP) ControlPoint library for Java/Kotlin
MIT License
50 stars 11 forks source link

Devices disappearing because of wrong expireTime #34

Closed sebcou21 closed 3 years ago

sebcou21 commented 3 years ago

Hi there,

First thanks for this great library.

I discovered an issue where devices disappear because of incorrect expireTime value. This value is set on object construction and is thus never updated when updateSsdpMessage is called with newer messages. It causes the device lost calculation to evict the device after the original expiry time has passed.

https://github.com/ohmae/mmupnp/blob/bb6696cc35d02059f4f019df4ea062b367ba05d0/mmupnp/src/main/java/net/mm2d/upnp/internal/impl/DeviceImpl.kt#L48

Modifying the property with a getter solves the issue:

override val expireTime: Long
    get() = ssdpMessage.expireTime

I have not assessed impacts of this modification or checked if other properties of DeviceImpl suffer the same issue.

Thank in advance.

ohmae commented 3 years ago

Hi,

As you pointed out, that's a bug. I've fixed it(https://github.com/ohmae/mmupnp/commit/cd63dd6ed87b6157822c41720411dc8b7b60a7c9) and released 3.1.2.

Thank you!

sebcou21 commented 3 years ago

Hi,

Thanks for correcting this quickly. It works in the new version.

Best regards.