Jey-Cee / ioBroker.upnp

Serves for communication and interaction with all upnp-capable devices.
MIT License
10 stars 8 forks source link

Adapter crash if section 'USN' is not defined in header #15

Closed Thisoft closed 6 years ago

Thisoft commented 6 years ago

While autodiscover crash the adapter if in the header the section 'USN' is not defined.

2017-12-28 12:19:25.547 - info: upnp.0 ***TEST***{"HOST":"239.255.255.250:1900","CACHE-CONTROL":"max-age=5000","LOCATION":"http://192.168.137.50/upnp/basic_dev.cgi","NTS":"ssdp:alive","SERVER":"HomeMatic","NT":"upnp:rootdevice"} 2017-12-28 12:19:25.609 - error: upnp.0 uncaught exception: Cannot read property 'toString' of undefined 2017-12-28 12:19:25.613 - error: upnp.0 TypeError: Cannot read property 'toString' of undefined at SsdpServer.<anonymous> (C:\ioBroker\node_modules\iobroker.upnp\main.js:1061:14) at emitOne (events.js:96:13) at SsdpServer.emit (events.js:188:7) at SsdpServer.SSDP._notify (C:\ioBroker\node_modules\iobroker.upnp\node_modules\node-ssdp\lib\index.js:256:12) at SsdpServer.parseCommand [as _parseCommand] (C:\ioBroker\node_modules\iobroker.upnp\node_modules\node-ssdp\lib\index.js:227:12) at SsdpServer.SSDP._parseMessage (C:\ioBroker\node_modules\iobroker.upnp\node_modules\node-ssdp\lib\index.js:210:10) at Socket.onSocketMessage (C:\ioBroker\node_modules\iobroker.upnp\node_modules\node-ssdp\lib\index.js:163:10) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:548:8) 2017-12-28 12:19:25.625 - info: upnp.0 Alive and sid states cleared 2017-12-28 12:19:25.626 - info: upnp.0 cleaned everything up... 2017-12-28 12:19:25.841 - info: upnp.0 terminating

To log the header I've modified the code in main.js:

server.on('advertise-alive', function (headers) { var usn = JSON.stringify(headers['USN']); if (typeof(usn)=="undefined") { adapter.log.info("***TEST***" + JSON.stringify(headers)); } usn = usn.toString();

Jey-Cee commented 6 years ago

Danke für deine Meldung. Ich werde eine Fehlerbehandlung ein bauen. Dauert aber ein paar Wochen bis ich Zeit dafür habe.

Thisoft commented 6 years ago

Alles klar. Danke.

Jey-Cee commented 6 years ago

Should be fixed now.