bencevans / soyes

(WIP) A web-based controller for Sonos devices.
6 stars 1 forks source link

unhandled 'error' event - win x64, node 0.10.7 #1

Closed ghchinoy closed 11 years ago

ghchinoy commented 11 years ago

Hi, this looks like a great start - I'm really interested in using node-sonos!

I'm getting this error when starting the soyes server (similar to the errors I'm getting with the node-sonos lib). I'd changed line 35 to be the ip of my ZoneBridge. Not clear on how to debug this.

Any ideas?

c:\dev\sonos\soyes>node server.js

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: bind EINVAL
    at errnoException (dgram.js:440:11)
    at dgram.js:207:28
    at dns.js:72:18
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:901:3
bencevans commented 11 years ago

Hi,

I don't use Windows as my primary desktop but I think this might be the problem ...

Because the Sonos search function (from node-sonos) binds to the UDP port 1900 to send and receive announcements from Sonos devices on the network, on Windows you may need to run the node.js with administrator permissions to allow this to happen.

If running node with administrator permissions doesn't fix it, please let us know the version of node you are using (node -v) and the version of windows you're running and I'll try and recreate the error here.

Cheers,

Ben

On 31/05/13 23:53, G. Hussain Chinoy wrote:

Hi, this looks like a great start - I'm really interested in using node-sonos!

I'm getting this error when starting the soyes server (similar to the errors I'm getting with the node-sonos lib).

Any ideas?

|c:\dev\sonos\soyes>node server.js

events.js:72 throw er; // Unhandled 'error' event ^ Error: bind EINVAL at errnoException (dgram.js:440:11) at dgram.js:207:28 at dns.js:72:18 at process._tickCallback (node.js:415:13) at Function.Module.runMain (module.js:499:11) at startup (node.js:119:16) at node.js:901:3 ''' |

— Reply to this email directly or view it on GitHub https://github.com/bencevans/soyes/issues/1.

ghchinoy commented 11 years ago

I'm using node v0.10.7

Trying with an administrator command prompt yields the same error.

This is what I receive with a test node-sonos script - not sure if it's the same or a related issue.

var sonos = require('sonos');

var s = new sonos.Sonos('192.168.1.103');
s.currentTrack(console.log);

results in { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

ghchinoy commented 11 years ago

This might be the issue. I'll have to fire up a linux vm it seems: https://github.com/joyent/node/issues/5587

bencevans commented 11 years ago

That's odd, does this happen if you run it a few times?

I don't believe it to be the joyent/node#5587 as there are no UDP/dgram packets/listeners in the currentTrack function, it is just a HTTP request.

A few things to try:

  1. Is your sonos device responding/working with a Sonos phone or windows app currently without a problem?
  2. Is your sonos device doing an update?
  3. Do these functions work, such as s.stop(console.log), s.deviceDescription(console.log) and s.getTopology(console.log)

I ask for all 3 functions in no. 3 as they use different methods of obtaining the data (SOAP, XML Doc & HTTP debug scrape).

ghchinoy commented 11 years ago

Thanks for your help here, I appreciate the debugging assist. My Android and Windows Sonos apps are connecting to both Play:3's. No update is in progress.

Looks like the 2nd one is working...

s.stop(console.log) yields: { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

s.deviceDescription(console.log); yields (success!?):

null { deviceType: 'urn:schemas-upnp-org:device:ZonePlayer:1',
  friendlyName: '192.168.1.103 - Sonos BRIDGE',
  manufacturer: 'Sonos, Inc.',
  manufacturerURL: 'http://www.sonos.com',
  modelNumber: 'ZB100',
  modelDescription: 'Sonos BRIDGE',
  modelName: 'Sonos ZoneBridge ZB100',
  modelURL: 'http://www.sonos.com/store/products/BRIDGE',
  softwareVersion: '22.0-64240',
  hardwareVersion: '1.5.0.0-1',
  serialNum: '00-0E-58-XX-XX-XX:6',
  UDN: 'uuid:RINCON_XXXXXXXXX',
  iconList: { icon: [ [Object] ] },
  minCompatibleVersion: '21.1-00000',
  displayVersion: '4.1',
  extraVersion: '',
  roomName: 'BRIDGE',
  displayName: 'BRIDGE',
  zoneType: '4',
  feature1: '0x00000000',
  feature2: '0x00008173',
  feature3: '0x00030000',
  internalSpeakerSize: '-1',
  serviceList: { service: [ [Object], [Object], [Object], [Object] ] },
  deviceList: '' }

s.getTopology(console.log); yields:

{ ZPSupportInfo: { ZonePlayers: [ [Object] ] } }

TypeError: Cannot read property '0' of undefined
    at c:\dev\sonos\nodeapp\node_modules\sonos\lib\sonos.js:546:67
    at Parser.<anonymous> (c:\dev\sonos\nodeapp\node_modules\xml2js\lib\xml2js.js:246:20)
    at Parser.EventEmitter.emit (events.js:95:17)
    at Object.saxParser.onclosetag (c:\dev\sonos\nodeapp\node_modules\xml2js\lib\xml2js.js:225:24)
    at emit (c:\dev\sonos\nodeapp\node_modules\xml2js\node_modules\sax\lib\sax.js:589:33)
    at emitNode (c:\dev\sonos\nodeapp\node_modules\xml2js\node_modules\sax\lib\sax.js:594:3)
    at closeTag (c:\dev\sonos\nodeapp\node_modules\xml2js\node_modules\sax\lib\sax.js:834:5)
    at Object.write (c:\dev\sonos\nodeapp\node_modules\xml2js\node_modules\sax\lib\sax.js:1253:29)
    at Parser.exports.Parser.Parser.parseString (c:\dev\sonos\nodeapp\node_modules\xml2js\lib\xml2js.js:264:29)
    at Parser.parseString (c:\dev\sonos\nodeapp\node_modules\xml2js\lib\xml2js.js:77:45)
ghchinoy commented 11 years ago

Also, if I run a test script with s.getCurrentTrack(console.log); I'll get a few of these [Error: HTTP response code 405 for "urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo"]

thrown in with the more frequent { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

bencevans commented 11 years ago

I think this might be the problem, because it's a bridge it doesn't have all the audio services as it just provides a WiFi for your other sonos devices. Try using the IP address of a ZonePlayer (one that plays music) and see if that yields something more positive ;)

ghchinoy commented 11 years ago

Aha, ok, that makes a lot of sense. Putting in the IP of a PLAY:3 yields successful json every time! Definitely on my way to working with node+sonos!

That's the node-sonos part, but putting in the same PLAY:3 IP into the soyes server.js is still giving the original Error: bind EINVAL error.

bencevans commented 11 years ago

Do you have the Sonos Controller currently open or another program that may be using the UDP port 1900?

Getting EINVAL for bind() indicates that the address to bind to might still be in use. - StackOverflow

ghchinoy commented 11 years ago

netstat -an shows nothing listening on my win box's 1900, and I did close my Android device's Sonos Controller. I don't have the Sonos Controller running on Windows, either.

bencevans commented 11 years ago

Hmmm, weird. I'll boot up a windows machine tomorrow and give it a go! :smiley_cat:

ghchinoy commented 11 years ago

Sounds good, thanks for your help!

ghchinoy commented 11 years ago

FWIW, fired up an ubuntu vm with node 0.10.9 and soyes starts on port 3000! some broken images, etc. but I'm past my initial errors. Thank you again!

bencevans commented 11 years ago

Awesome, no problem! I'll still have a hunt for the reasoning behind the windows prob. tomorrow though.

The broken images are from when I was designing and haven't made it dynamic to current content yet. You're very welcome to hack away and submit pull-requests :wink:

Also you might want to git pull then npm install the updates from the repo as I made some tiny changes earlier

jhelmink commented 11 years ago

Commenting to follow this as I'm getting the same error (Win 7 32 bit Node v0.10.9)

C:\Users\Win7-Dev\Documents\GitHub\soyes>node server

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: bind EINVAL
    at errnoException (dgram.js:440:11)
    at dgram.js:207:28
    at dns.js:72:18
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:901:3
bencevans commented 11 years ago

Thanks @jhelmink, is this also when running node with Administrator Privileges? (not just an account that has access to admin privileges)

bencevans commented 11 years ago

@ghchinoy I've found so far that it works without any problems (on windows) using Node.js v0.8.23 but I too am getting the same error on v0.10.7.

jhelmink commented 11 years ago

Sorry for the late reply, just noticed I had the wrong email address for this account (so no notification!)

@ghchinoy I was able to download the v0.8.23 node.exe here; http://nodejs.org/dist/v0.8.23/node.exe which I was able to use in the soyes directory (despite having v0.10.9 installed which I guess is where all the modules are being pulled from)

ghchinoy commented 11 years ago

Ok, thanks @bencevans and @jhelmink - looks like I'll try v0.8.23 - I'd upgraded to v0.10.9 to see if that helped, but as you two noted, it hasn't. Any thoughts as to why the 0.10 line's changed on Windows? Thanks again!