GENA message fully ignored if there is a data type problem for one state variable
lolodomo opened this issue · 3 comments
By implementing the invalidMessage method in the openHAB Sonos binding, I discovered that few received GENA events are ignored due to an error for one of thge state variable (bad type of the value):
2018-06-03 02:56:29.622 [ERROR] [.e.s.i.t.u.i.UpnpIOServiceImpl:203 ] - invalidMessageorg.jupnp.model.UnsupportedDataException: Can't transform message payload: Can't convert string to number or not in range: RINCON_000E588EAE6601400,175
at org.jupnp.transport.impl.GENAEventProcessorImpl.readBody(GENAEventProcessorImpl.java:99)
at org.jupnp.protocol.sync.ReceivingEvent.executeSync(ReceivingEvent.java:95)
at org.jupnp.protocol.sync.ReceivingEvent.executeSync(ReceivingEvent.java:1)
at org.jupnp.protocol.ReceivingSync.execute(ReceivingSync.java:62)
at org.jupnp.protocol.ReceivingAsync.run(ReceivingAsync.java:69)
at org.jupnp.transport.spi.UpnpStream.process(UpnpStream.java:81)
at org.jupnp.transport.impl.ServletUpnpStream.run(ServletUpnpStream.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jupnp.model.types.InvalidValueException: Can't convert string to number or not in range: RINCON_000E588EAE6601400,175
at org.jupnp.model.types.UnsignedIntegerFourBytesDatatype.valueOf(UnsignedIntegerFourBytesDatatype.java:27)
at org.jupnp.model.types.UnsignedIntegerFourBytesDatatype.valueOf(UnsignedIntegerFourBytesDatatype.java:1)
at org.jupnp.model.VariableValue.<init>(VariableValue.java:52)
at org.jupnp.model.state.StateVariableValue.<init>(StateVariableValue.java:32)
at org.jupnp.transport.impl.GENAEventProcessorImpl.readProperties(GENAEventProcessorImpl.java:162)
at org.jupnp.transport.impl.GENAEventProcessorImpl.readBody(GENAEventProcessorImpl.java:96)
at org.jupnp.protocol.sync.ReceivingEvent.executeSync(ReceivingEvent.java:95)
at org.jupnp.protocol.sync.ReceivingEvent.executeSync(ReceivingEvent.java:1)
at org.jupnp.protocol.ReceivingSync.execute(ReceivingSync.java:62)
at org.jupnp.protocol.ReceivingAsync.run(ReceivingAsync.java:69)
at org.jupnp.transport.spi.UpnpStream.process(UpnpStream.java:81)
Caused by: java.lang.NumberFormatException: For input string: "RINCON_000E588EAE6601400,175"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at org.jupnp.model.types.UnsignedVariableInteger.<init>(UnsignedVariableInteger.java:61)
at org.jupnp.model.types.UnsignedIntegerFourBytes.<init>(UnsignedIntegerFourBytes.java:27)
at org.jupnp.model.types.UnsignedIntegerFourBytesDatatype.valueOf(UnsignedIntegerFourBytesDatatype.java:25)
at org.jupnp.model.types.UnsignedIntegerFourBytesDatatype.valueOf(UnsignedIntegerFourBytesDatatype.java:1)
at org.jupnp.model.VariableValue.<init>(VariableValue.java:52)
at org.jupnp.model.state.StateVariableValue.<init>(StateVariableValue.java:32)
at org.jupnp.transport.impl.GENAEventProcessorImpl.readProperties(GENAEventProcessorImpl.java:162)
at org.jupnp.transport.impl.GENAEventProcessorImpl.readBody(GENAEventProcessorImpl.java:96)
The exception is caught here:
https://github.com/jupnp/jupnp/blob/master/bundles/org.jupnp/src/main/java/org/jupnp/transport/impl/GENAEventProcessorImpl.java#L98
Rather than throwing an exception, I think we should continue with all correct state variables in the message and just ignore the wrong ones.
The Sonos binding is not receiving notification from the ContentDirectory service and the probability that this is due to this problem is very high.
I propose to be less strict and just ignore wrong state variables.
WDYT ?
I am now certain that the error is relative to the subscription to the ContentDirectory service because the error disappears when I avoid this subscription.
I would not be surprised that the problem is with the state variable RadioFavoritesUpdateID
with a defined data type of ui4
while the value is a string. Of course, the real bug is inside the Sonos software but this bug should not trigger a full reject of the received event.
I finally got it running in my OH Eclipse environment...
Fixed by #98.