Add XBMC Connection Fails

Adding an XBMC connection fails on the latest release.

A manual JSON query from the NZBDrone server to the XBMC server succeeds though, go figure!

My guess is the json request is not being sent correctly considering xbmc logs receiving the request but does not parse it - feel free to tell me how far off i am :slight_smile:

I tried to collect as much information as humanely possible but please let me know if you need more information!

Configuration

NZBDrone Version  : 2.0.0.1690
NZBDrone OS       : CentOS 6.5 - 2.6.32-431.20.3.el6.x86_64

XBMC Version : XBMC (12.3 Git:9ed3e58)
XBMC OS : Ubuntu 12.10 - 3.5.0-25-generic i686

Failure Scenario:

  • Add XBMC host info as an NZBDrone Connection
  • Click Test or Save

NZBDrone Log Output

This is what the nzbdrone log shows when attempting to test or save a connection to xbmc.

14-7-25 08:20:18.4|Debug|XbmcService|Determining version of XBMC Host: 192.168.1.105:8080
14-7-25 08:20:18.4|Debug|HttpProvider|Posting command: {
  "jsonrpc": "2.0",
  "method": "JSONRPC.Version",
  "id": 1
}, to http://192.168.1.105:8080/jsonrpc

14-7-25 08:21:58.4|Debug|XbmcService|The request timed out

System.Net.WebException: The request timed out
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
  at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in <filename unknown>:0
  at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in <filename unknown>:0
  at System.Net.WebClient.UploadDataCore (System.Uri address, System.String method, System.Byte[] data, System.Object userToken) [0x00000] in <filename unknown>:0
  at System.Net.WebClient.UploadData (System.Uri address, System.String method, System.Byte[] data) [0x00000] in <filename unknown>:0

14-7-25 08:21:58.4|Debug|XbmcService|Version is: 0.0.0
14-7-25 08:21:58.4|Error|XbmcService|Unable to send test message: Verion received from XBMC is invalid, please correct your settings.

NzbDrone.Core.Notifications.Xbmc.InvalidXbmcVersionException: Verion received from XBMC is invalid, please correct your settings.
  at NzbDrone.Core.Notifications.Xbmc.XbmcService.Test (NzbDrone.Core.Notifications.Xbmc.XbmcSettings settings) [0x00000] in <filename unknown>:0

14-7-25 08:21:58.4|Warn|NzbDroneErrorPipeline|Invalid request Validation failed:
 -- Unable to send test message

XBMC Log

The XBMC log during during the NZBDrone connection attempt

08:56:26 T:2865838912   DEBUG: webserver: request received for /jsonrpc

Manual JSON

The same json command works if manually initiated from the command line on the server hosting nzbdrone - this should rule out connection issues or XBMC issues.

Manual Command

curl -i -X POST                                                  \
     -H 'Content-Type: application/json'                         \
     -d '{"jsonrpc": "2.0","method": "JSONRPC.Version","id": 1}' \
     http://xbmc:xbmc@192.168.1.105:8080/jsonrpc

Command Output

[nzbdrone@media-server logs]# curl -i -X POST             \
>                                  -H 'Content-Type: application/json'      \
>                                  -d '{"jsonrpc": "2.0","method": "JSONRPC.Version","id": 1}' \
>                                   http://xbmc:xbmc@192.168.1.105:8080/jsonrpc
HTTP/1.1 200 OK
Content-Length: 77
Content-Type: application/json
Date: Fri, 25 Jul 2014 13:38:49 GMT

{"id":1,"jsonrpc":"2.0","result":{"version":{"major":6,"minor":0,"patch":3}}}

XBMC Log

The xbmc log of the successful request

09:12:57 T:2857446208   DEBUG: webserver: request received for /jsonrpc
09:12:57 T:2857446208   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0","method": "JSONRPC.Version","id": 1}
09:12:57 T:2857446208   DEBUG: JSONRPC: Calling jsonrpc.version

So i upgraded XBMC to v13.0 in hopes it resolves this issue but it didn’t make a difference.

I even tried reinstalling nzbdrone - i’m just surprised no one else is reporting this issue!

It has come up before, searching for XBMC returns a few results and this is in the top 5: http://forums.nzbdrone.com/t/xbmc-not-being-updated/1004

Do you have a password set on XBMC? If you turn if off do you still have issues?

There seems to be problems when XBMC has a password set, but its not always an issue. I never have an issue, but others have nothing but issues.

Well what do you know! Removing the password solved my issue. I can’t believe that didn’t occur to me after spending all that time debugging. Oh well, didn’t really need the password on my LAN anyways.

Shouldn’t this be a bug though?

The json query can include the password like this:

http://xbmc:xbmc@192.168.1.105:8080/jsonrpc

Now my nzbdrone log shows:

14-7-27 19:20:45.3|Debug|XbmcService|Determining version of XBMC Host: 192.168.1.105:8080
14-7-27 19:20:45.3|Debug|HttpProvider|Posting command: {
  "jsonrpc": "2.0",
  "method": "JSONRPC.Version",
  "id": 1
}, to http://192.168.1.105:8080/jsonrpc
14-7-27 19:20:45.3|Debug|XbmcService|Getting version from response: {"id":1,"jsonrpc":"2.0","result":{"version":{"major":6,"minor":14,"patch":3}}}
14-7-27 19:20:45.3|Debug|XbmcService|Version is: 6.14.3
14-7-27 19:20:45.3|Debug|HttpProvider|Posting command: {
  "jsonrpc": "2.0",
  "method": "JSONRPC.Version",
  "id": 1
}, to http://192.168.1.105:8080/jsonrpc
14-7-27 19:20:45.3|Debug|XbmcService|Getting version from response: {"id":1,"jsonrpc":"2.0","result":{"version":{"major":6,"minor":14,"patch":3}}}
14-7-27 19:20:45.3|Debug|HttpProvider|Posting command: {
  "jsonrpc": "2.0",
  "method": "GUI.ShowNotification",
  "params": {
    "title": "Test Notification",
    "message": "Success! XBMC has been successfully configured!",
    "image": "https://raw.github.com/NzbDrone/NzbDrone/develop/Logo/64.png",
    "displaytime": 5000
  },
  "id": 2
}, to http://192.168.1.105:8080/jsonrpc

and my xbmc log is still just:

webserver: request received for /jsonrpc

Notification is working now - guess the password wasn’t being user/pass weren’t being passed correctly.

Yeah, it’s an issue, but the username and password are being sent. The connection between drone and XBMC is unreliable when its enabled (XBMC will close or drop connections).

Unfortunately its almost impossible for UA to troubleshoot when we can’t reproduce it.

I’ll try to reproduce again and take a deeper look - wireshark might be useful to see what exactly is being exchanged between xbmc and nzbdrone. I’ll report back with any progress.

I think I found the cause and the solution, definitely an issue with XBMC’s API, but I think I have a work around.

Okay, just pushed the fix, working much much better in my tests, went from failing 1%+ of 1000 tests to 0% of 500k tests.

The issue was with how XBMC handled authentication when drone didn’t provide the credentials in the initial request, it would send back a 401, which drone would respond to, passing the credentials, but often XBMC would close the connection and drone would fail to authenticate properly. Now drone will send the authentication in the first request and not wait for the 401 response, means less calls between drone and XBMC and its reliable.

Hi,

I think I have the same issue but with all my Kodi add-ons. I get the same message:

webserver: request received for /jsonrpc
Previous line repeats 35 times.

This is a complete logging after reboot and requesting a youtube stream, waiting and cancelling the request:
http://pastebin.com/m7RDvxsr

Add-on is started but nothing happens, but “loading”, “opening” of “searching”

I have this with all my add-ons, like youtube and subtitles.
What was you sollution? Hope you can help me.

@suheyl

Just taking a quick glance at your log, this seems to be related to Kodi only, and has nothing to do with Sonarr?

If so, you are better posting for support over in the Kodi forums - http://forum.kodi.tv/

True and already did. But I thought it might be a similar issue. Thnx anyhow.