thibauts / node-upnp-mediarenderer-client

An UPnP/DLNA MediaRenderer client
MIT License
128 stars 30 forks source link

Can't connect to MediaRenderer (ECONNREFUSED) #7

Closed wallydz closed 9 years ago

wallydz commented 9 years ago

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

thibauts commented 9 years ago

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.

wallydz commented 9 years ago

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

wallydz commented 9 years ago

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 ...'); })

thibauts commented 9 years ago

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.

wallydz commented 9 years ago

may i ask what are the content of those headers ?

No it gave me the same Error i mentioned above

thibauts commented 9 years ago

Could you give me the full error stacktrace ?

wallydz commented 9 years ago

{ [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)

thibauts commented 9 years ago

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

thibauts commented 9 years ago

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 ?

wallydz commented 9 years ago

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)

thibauts commented 9 years ago

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

wallydz commented 9 years ago

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)

thibauts commented 9 years ago

Could you post the getServiceDescription for services ConnectionManager and AVTransport ?

thibauts commented 9 years ago

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.

wallydz commented 9 years ago

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' } } }

wallydz commented 9 years ago

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

thibauts commented 9 years ago

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

thibauts commented 9 years ago

Fix pushed to npm.

wallydz commented 9 years ago

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 ...'); });

thibauts commented 9 years ago

OK. We'll make this work !

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

wallydz commented 9 years ago

ConnectionManager https://gist.github.com/wallydz/add21b5420de1e046aae Avtransport : https://gist.github.com/wallydz/95a1fd1df6af9d0eb931 Rendering : https://gist.github.com/wallydz/1b0f8b12154270c2ec93

thibauts commented 9 years ago

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.

thibauts commented 9 years ago

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

thibauts commented 9 years ago

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

wallydz commented 9 years ago

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

thibauts commented 9 years ago

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).

wallydz commented 9 years ago

Fixed , Upnp Error now :+1: