timmson / node-lgtv-api

Node.js API for the remote control of LG SmartTV (2012+)
MIT License
25 stars 8 forks source link

Error: Response code:undefined #2

Closed aryeharmon closed 7 years ago

timmson commented 7 years ago

@aryeharmon, can you describe details of your cause, please? Or attach source code how you call api?

Mnark commented 7 years ago

I too have come across this issue. It appears to be caused by a slightly later version of LG TV. The issue seems to lie in the format of the XML payload being sent. I'll fork the code and see if I can diagnose a bit more...

timmson commented 7 years ago

@Mnark, I would like to help you, can you tell more details? Usually I test this lib against php version, that is mentioned in the top of README

Mnark commented 7 years ago

I think there are a couple of places in your code that are not handling errors correctly, which is making it harder to diagnose to the problem .... e.g. Line 154 there appears to be 'null' parameter always passed back as the first parameter. The actual error being throw is a 'socket hang up', but this is not being passed back correctly.

I'm still looking at the actual problem... I have a request working in 'Fiddler', so it should be possible to get it working in your code too.

timmson commented 7 years ago

Thanks for the feedback! Can you make a pull request with your edits?

Mnark commented 7 years ago

Yes, if I can get it working :)

Mnark commented 7 years ago

I have done an initial commit back to my repository (https://github.com/Mnark/node-lgtv-api).

I've got as far as getting the key-display working. I have introduced a tvType property to switch between the different TV's (defaulting to your version).

I was having trouble sending the XML using the 'request' module... so have used the node "http.request" module. (I suggest refactoring your calls to use this as well, as it reduces the number of external dependencies).

I don't think its worth doing a pull-request until I have had a chance to look at some more functionality.

Take a look, all comments welcome.