thibauts/node-upnp-mediarenderer-client

Can't connect to MediaRenderer (ECONNREFUSED)

wallydz opened this issue · 27 comments

Was trying inital test after getting Mediarender url using
https://github.com/stormboy/node-upnp-controlpoint

var MediaRendererClient = require('upnp-mediarenderer-client');

// Instanciate a client with a device description URL (discovered by SSDP)
var client = new MediaRendererClient('http://192.168.1.50:4873/urltomediarender.xml');

// Load a stream and play it immediately
client.load('http://url.to.some/stream.avi', { autoplay: true }, function(err, result) {
if(err) throw err;
console.log('playing ...');
});

Error : *****/dlna/node-upnp-mediarenderer-client/test.js:4
if(err) throw err;
^
Error: connect ECONNREFUSED
at errnoException (net.js:904:11)
at Object.afterConnect as oncomplete

Getting a Connection Refused all the time any idea why?

EDIT : Content of Mediarender.xml
https://gist.github.com/wallydz/2b363e5f92b6641619dd

Most likely the MediaRenderer URL is wrong. I've never used node-upnp-controlpoint but all you need is an SSDP client. I may open-source one if no published modules fit the bill.

Hmm i was checking the URL via browser and posted its content
https://gist.github.com/wallydz/2b363e5f92b6641619dd

Another one test with node-ssdp

var Client = require('node-ssdp').Client
, client = new Client();

client.on('response', function (headers, statusCode, rinfo) {
  console.log('Got a response to an m-search.');
    console.log(headers);

});
client.search('ssdp:all');
// console.log(headers);
var MediaRendererClient = require('./');
var client2 = new MediaRendererClient('http://192.168.0.116:52235/dmr/SamsungMRDesc.xml');
client2.load('http://us-chi.cdn.ptn.pm/nwtests/bb.mp4', { autoplay: true }, function(err, result) {
if(err) throw err;
console.log('playing ...');
})

So does it work ? We've played with a friend's Samsung TV and additional code was needed for DLNA compatibility in the HTTP server serving the video stream.

may i ask what are the content of those headers ?

No it gave me the same Error i mentioned above

Could you give me the full error stacktrace ?

{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
Trace
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/test.js:17:12
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/index.js:30:16
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:68:20
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:54:22
at ClientRequest. (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:225:20)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)

Thanks. Could you call getDeviceDescription on the client and paste the resulting JSON ?

BTW I just pushed the latest code to npm to have the line numbers in stack traces synced with the GH sources, could you please npm update ?

getDeviceDescription :
https://gist.github.com/wallydz/c4fd6789427ad8c0824c


{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
Trace
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/test.js:17:12
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/index.js:30:16
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:65:20
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:51:22
at ClientRequest. (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:222:20)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)

Ok bug spotted, I just commited a fix and pushed to npm. Let me know how it goes.

Error: Unexpected end
Line: 0
Column: 0
Char:
at error (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:347:8)
at end (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:354:32)
at Object.write (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:588:30)
at Object.SAXParser.close (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:136:38)
at XMLParser.close (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/parsers/sax.js:52:15)
at ElementTree.parse (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/elementtree.js:272:23)
at Object.parse (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/elementtree.js:584:8)
at /Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:224:18
at IncomingMessage. (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:288:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)

Could you post the getServiceDescription for services ConnectionManager and AVTransport ?

Well first post the getDeviceDescription again and try to browse to the SCDPURL for both these services. Please post them too if they don't 404.

services:
{ 'urn:upnp-org:serviceId:RenderingControl':
{ serviceType: 'urn:schemas-upnp-org:service:RenderingControl:1',
SCPDURL: 'http://192.168.0.116:52235/RenderingControl1.xml',
controlURL: 'http://192.168.0.116:52235/upnp/control/RenderingControl1',
eventSubURL: 'http://192.168.0.116:52235/upnp/event/RenderingControl1' },
'urn:upnp-org:serviceId:ConnectionManager':
{ serviceType: 'urn:schemas-upnp-org:service:ConnectionManager:1',
SCPDURL: 'http://192.168.0.116:52235/ConnectionManager1.xml',
controlURL: 'http://192.168.0.116:52235/upnp/control/ConnectionManager1',
eventSubURL: 'http://192.168.0.116:52235/upnp/event/ConnectionManager1' },
'urn:upnp-org:serviceId:AVTransport':
{ serviceType: 'urn:schemas-upnp-org:service:AVTransport:1',
SCPDURL: 'http://192.168.0.116:52235/AVTransport1.xml',
controlURL: 'http://192.168.0.116:52235/upnp/control/AVTransport1',
eventSubURL: 'http://192.168.0.116:52235/upnp/event/AVTransport1' } } }

Both of them are 404 as normally it should be http://192.168.0.116:52235/dmr/RenderingControl1.xml

Oh yeah of course .. Let me see what I can do.

Fix pushed to npm.

Same issue but now getDeviceDescription have correct URL
services:
{ 'urn:upnp-org:serviceId:RenderingControl':
{ serviceType: 'urn:schemas-upnp-org:service:RenderingControl:1',
SCPDURL: 'http://192.168.0.116:52235/dmr/RenderingControl1.xml',
controlURL: 'http://192.168.0.116:52235/dmr/upnp/control/RenderingControl1',
eventSubURL: 'http://192.168.0.116:52235/dmr/upnp/event/RenderingControl1' },
'urn:upnp-org:serviceId:ConnectionManager':
{ serviceType: 'urn:schemas-upnp-org:service:ConnectionManager:1',
SCPDURL: 'http://192.168.0.116:52235/dmr/ConnectionManager1.xml',
controlURL: 'http://192.168.0.116:52235/dmr/upnp/control/ConnectionManager1',
eventSubURL: 'http://192.168.0.116:52235/dmr/upnp/event/ConnectionManager1' },
'urn:upnp-org:serviceId:AVTransport':
{ serviceType: 'urn:schemas-upnp-org:service:AVTransport:1',
SCPDURL: 'http://192.168.0.116:52235/dmr/AVTransport1.xml',
controlURL: 'http://192.168.0.116:52235/dmr/upnp/control/AVTransport1',
eventSubURL: 'http://192.168.0.116:52235/dmr/upnp/event/AVTransport1' } } }

But same error

Error: Unexpected end
Line: 0
Column: 0
Char:
at error (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:347:8)
at end (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:354:32)
at Object.write (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:588:30)
at Object.SAXParser.close (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:136:38)
at XMLParser.close (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/parsers/sax.js:52:15)
at ElementTree.parse (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/elementtree.js:272:23)
at Object.parse (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/elementtree.js:584:8)
at IncomingMessage. (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:122:22)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:919:16


for this code
var MediaRendererClient = require('./');
var client2 = new MediaRendererClient('http://192.168.0.116:52235/dmr/SamsungMRDesc.xml');
client2.load('http://us-chi.cdn.ptn.pm/nwtests/bb.mp4', { autoplay: true }, function(err, result) {
if(err){
console.log(err);
console.trace();};
console.log('playing ...');
});

OK. We'll make this work !

Can you please post the XML for both services mentioned earlier ?

My bad, it happens during a SOAP call, in callAction (upnp-device-client, index.js, line 122).

Could you provide a console.log of the buf.toString() that appears on this line ? Please make sure this is the one that fails, as there may be multiple calls.

While you're at it, log res.statusCode ...

Logging the params of this callAction may help too. Namely serviceId, actionName, params. Thanks

https://gist.github.com/wallydz/3477ca0790b1e2ffabce

  • Error: Unexpected end
    Line: 0
    Column: 0
    Char:
    at error (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:347:8)
    at end (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:354:32)
    at Object.write (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:588:30)
    at Object.SAXParser.close (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/node_modules/sax/lib/sax.js:136:38)
    at XMLParser.close (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/parsers/sax.js:52:15)
    at ElementTree.parse (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/elementtree.js:272:23)
    at Object.parse (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/node_modules/elementtree/lib/elementtree.js:584:8)
    at IncomingMessage. (/Users/wally/po/dlna/node-upnp-mediarenderer-client/node_modules/upnp-device-client/index.js:125:15)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:919:16

OK, seems like I had a hard time getting absolute URL building right :) Should be OK now. Fix pushed to npm. If it is OK on your side and you get to the point of either playing your content or getting a regular UPNP error, please close this issue (and open a new one).

Fixed , Upnp Error now 👍