Kodi Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263)



- Zarquon - 2010-11-22

Recently noticed a problem. When I switch to another profile and then back to the Master profile, the JSON-RPC no longer responds. Works fine before the switch and after the switch to the other profile but not when I return to the master. It also starts working again if I leave the master profile.

Any Ideas?

FYI Running Ubuntu 10.04 Dharma RC1 on a Acer Revo 3610 - Installed xbmcFreaks Beta 4 Live CD and upgraded via apt-get to RC1

Edit Additional detail: Here is a link to the xbmc.log http://pastebin.com/44TdNW1m Note I turned on detailed logging after the first change of profile and return.

So the JSONRPC worked and didn't as follows:
  • 2:06:31 Working in Master Profile
  • 2:08:22 Working in Alt Profile
  • 2:09:23 NOT Working in Master Profile
  • Debug Logging Enabled
  • 2:16:28 Working in Alt Profile
  • 2:18:10 Not Working in Master Profile



- grywnn - 2010-11-22

blinkseb Wrote:I've got some free time today, so here we go : http://trac.xbmc.org/ticket/10728

Four new json methods, each allowing to retrieve informations about a specific movie/tvshow/episode/music video

I'll add the same thing for music library if it's relevant.
You're my hero Smile
Music library would be nice, for example to query the review or genres for a specific album.


- topfs2 - 2010-11-22

Zarquon Wrote:Recently noticed a problem. When I switch to another profile and then back to the Master profile, the JSON-RPC no longer responds. Works fine before the switch and after the switch to the other profile but not when I return to the master. It also starts working again if I leave the master profile.

Any Ideas?

FYI Running Ubuntu 10.04 Dharma RC1 on a Acer Revo 3610 - Installed xbmcFreaks Beta 4 Live CD and upgraded via apt-get to RC1

Edit Additional detail: Here is a link to the xbmc.log http://pastebin.com/44TdNW1m Note I turned on detailed logging after the first change of profile and return.

So the JSONRPC worked and didn't as follows:
  • 2:06:31 Working in Master Profile
  • 2:08:22 Working in Alt Profile
  • 2:09:23 NOT Working in Master Profile
  • Debug Logging Enabled
  • 2:16:28 Working in Alt Profile
  • 2:18:10 Not Working in Master Profile

Please file a trac ticket so it doesn't get lost.


- spiff - 2010-11-22

there's already a ticket.


- topfs2 - 2010-11-24

For all client creators some changes have happened between RC1 and stable which might be valid to know about which will be in effect in Dharma.

GetAnnouncementFlags now returns an object which is the same object you can send to SetAnnouncementFlags. Not that the object is case sensative and the casing is the same as in the getter.

Permission have been changed to follow the same schema although there is no way to alter permissions at this point but might be added in next version.

Speaking of versions with RC1 jsonrpc was bumped to 2 in Dharma and 3 in trunk. So with this odd numbers refers to development versions and should be considered moving targets and everything can happen with them Smile. Even numbers will be for stable releases.

Those that have followed trac there have been quite some activity regarding announcements in version 3 and thanks to blinksebs help jsonrpc is starting to be quite chatty.

For the roadmap of version 4 is getting announcements much more reliable and informative. The hope is that the announcements should be enough so that the client just need to keep a state machine and can only get data when an announcement occurs thus lowering the bandwith.

Some of the added announcements are UpdateAudio, RemoveAudio, UpdateVideo and RemoveVideo. All these will give you the same data which is a "content" field which tells you what to expect the id to be. The id is named as with the other get calls in the libraries and is usually content + "id", e.g. "tvshowid". Note that there exist no AddFoo as UpdateFoo covers this and an update can be both addition and refresh (just something you need to consider when coding).

On the roadmap is also to get the actual permissions sorted and the hope is that we can get that in properly for version 4. I'd love user scenarios and thoughts on the subject but here is some scenarios that will be used for consideration:
  1. Client uses TCP for announcements but controls xbmc over HTTP. As such all authorization should be sharable over transports, i.e. one client must be able to use multiple transports with same permissions
  2. A client connects but xbmc is able to restart before the client have noticed (viable on http). As such the client permissions needs to be stored on server

1) just means that a client should be able to use the same token on multiple transports.
2) Is harder to fix without sending the token all the time and it might be up to the client to catch the error and re-auth.

Any more feature requests for version 4? Any questions?

Cheers,
Tobias


- Montellese - 2010-11-24

Hey

I don't know if this is the right place to post this but as I think the problem is related to JSON RPC and XBMCs webserver I thought I'd post it here first and if it's not the right place someone can point me to where to post this best.

When I'm running my "XBMC on iMON Display" application using JSON RPC to retrieve all the information from XBMC it often happens that XBMC crashes on shutdown. I did it a few times with debug logging enabled and compared the log files and they always look the same after a crash.

This is how the end of the log file looks when the shutdown doesn't crash:
Code:
08:31:23 T:5212 M:1053921280   DEBUG: CAnnouncementManager - Announcement: ApplicationStop from xbmc
08:31:23 T:5212 M:1053913088  NOTICE: Storing total System Uptime
08:31:23 T:5212 M:1053917184  NOTICE: Saving settings
08:31:23 T:5212 M:1053954048  NOTICE: stop all
08:31:23 T:5212 M:1053954048   DEBUG: CNetwork::NetworkMessage - Signaling network services to stop
08:31:23 T:5212 M:1053949952  NOTICE: ES: Stopping event server
08:31:23 T:5212 M:1053945856   DEBUG: CNetwork::NetworkMessage - Waiting for network services to stop
08:31:23 T:5212 M:1053945856  NOTICE: Webserver: Stopping...
08:31:23 T:5212 M:1053958144  NOTICE: WebServer: Stopped the webserver
08:31:23 T:5212 M:1053958144  NOTICE: Webserver: Stopped...
08:31:23 T:3976 M:1053999104    INFO: JSONRPC Server: Disconnection detected
08:31:23 T:3976 M:1053999104   DEBUG: Thread 3976 terminating
08:31:23 T:1724 M:1053757440  NOTICE: ES: UDP Event server stopped
08:31:23 T:1724 M:1053757440   DEBUG: Thread 1724 terminating
08:31:23 T:5212 M:1053790208  NOTICE: stop player
08:31:23 T:5132 M:1053790208    INFO: PAPlayer: End of playback reached
08:31:23 T:5132 M:1053790208   DEBUG: CAnnouncementManager - Announcement: PlaybackStopped from xbmc
08:31:23 T:5132 M:1053790208   DEBUG: PAPlayer: Thread end
08:31:23 T:5132 M:1053790208   DEBUG: Thread 5132 terminating
08:31:23 T:4632 M:1054523392   DEBUG: Thread 4632 terminating
08:31:23 T:5212 M:1060118528   DEBUG: CWin32DirectSound::Deinitialize: Cleaning up
08:31:23 T:5212 M:1060163584  NOTICE: stop sap announcement listener
08:31:23 T:5212 M:1060163584  NOTICE: clean cached files!
08:31:23 T:5212 M:1060319232  NOTICE: unload skin
08:31:23 T:5212 M:1060319232   DEBUG: ------ Window Deinit (Home.xml) ------
08:31:23 T:5212 M:1060319232   DEBUG: ------ Window Deinit (MusicOverlay.xml) ------
08:31:23 T:5212 M:1060319232   DEBUG: ------ Window Deinit (Pointer.xml) ------
08:31:23 T:5212 M:1060319232   DEBUG: ------ Window Deinit (DialogMuteBug.xml) ------
08:31:23 T:5212 M:1084399616  NOTICE: stop python
08:31:24 T:5212 M:1111687168  NOTICE: stopped
08:31:24 T:5212 M:1111683072  NOTICE: destroy
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC3C40 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC37C0 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC3C88 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CE0110 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC3898 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CE0860 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CE01E8 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CDFFA8 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC3B68 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC36E8 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC39B8 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840    INFO: ADDON: cpluff: 'An unreleased information object was encountered at address 02CC3778 with reference count 1 when destroying the associated plug-in context. Not releasing the object.'
08:31:24 T:5212 M:1111715840  NOTICE: unload sections
08:31:24 T:5212 M:1111715840   DEBUG: SECTION:UnloadAll(SECTION: LIBHTTP)
08:31:24 T:5212 M:1111715840   DEBUG: SECTION:UnloadAll(DLL: special://xbmcbin/system/cpluff.dll)
08:31:24 T:5212 M:1111715840   DEBUG: Win32DllLoader::Unload cpluff.dll
08:31:24 T:5212 M:1111715840   DEBUG: FreeLibrary(libexpat.dll) -> 022B8950
08:31:24 T:5212 M:1111715840   DEBUG: Win32DllLoader::Unload libexpat.dll
08:31:24 T:5212 M:1111896064   DEBUG: SECTION:UnloadAll(DLL: special://xbmcbin/system/ImageLib.dll)
08:31:24 T:5212 M:1111896064   DEBUG: Win32DllLoader::Unload ImageLib.dll
08:31:24 T:5212 M:1112223744   DEBUG: SECTION:UnloadAll(DLL: special://xbmcbin/system/players/dvdplayer/libmad.dll)
08:31:24 T:5212 M:1112223744   DEBUG: Win32DllLoader::Unload libmad.dll
08:31:24 T:5212 M:1112297472   DEBUG: SECTION:UnloadAll(DLL: special://xbmcbin/system/libid3tag.dll)
08:31:24 T:5212 M:1112297472   DEBUG: Win32DllLoader::Unload libid3tag.dll
08:31:24 T:5212 M:1112453120    INFO: lastfm destroyed

and this is how it looks when it crashes:
Code:
08:32:03 T:4660 M:1068199936   DEBUG: CAnnouncementManager - Announcement: ApplicationStop from xbmc
08:32:03 T:4660 M:1068199936  NOTICE: Storing total System Uptime
08:32:03 T:4660 M:1068199936  NOTICE: Saving settings
08:32:03 T:5532 M:1068199936    INFO: JSONRPC Server: Disconnection detected
08:32:03 T:4660 M:1068011520  NOTICE: stop all
08:32:03 T:4660 M:1068011520   DEBUG: CNetwork::NetworkMessage - Signaling network services to stop
08:32:03 T:4660 M:1068011520  NOTICE: ES: Stopping event server
08:32:03 T:4660 M:1068007424   DEBUG: CNetwork::NetworkMessage - Waiting for network services to stop
08:32:03 T:4660 M:1068007424  NOTICE: Webserver: Stopping...
08:32:03 T:336 M:1068007424  NOTICE: ES: UDP Event server stopped
08:32:03 T:336 M:1068007424   DEBUG: Thread 336 terminating
08:32:04 T:5532 M:1068019712   DEBUG: Thread 5532 terminating

Of course the terminated thread numbers vary but I noticed that it never gets to
Code:
08:31:23 T:5212 M:1053958144  NOTICE: WebServer: Stopped the webserver
08:31:23 T:5212 M:1053958144  NOTICE: Webserver: Stopped...

I also have an idea why this might be happening: In my application I have an option to enable polling XBMCs CurrentControl info label every 500 ms. This allows to display the label of the current control on the LCD display and therefore it is possible to use XBMC without turning on the TV. BUT on shutdown it might happen that a GetInfoLabels() call is sent right before/after the ApplicationStop announcement arrived. Now XBMC is already shutting down its webserver but receives another request and might not know what to do.

I want to emphasize that this is only an idea I had because I noticed that everytime XBMC crashes on shutdown I get errors in the log of my application and when it doesn't crash there are no errors either.

I'll see if I can get rid of the calls causing the problem but if it is really as I suspect XBMC shouldn't really crash just because there is some stupid application (which might not listen to the announcements) calls another JSON RPC method when XBMC doesn't expect it.


- staeff - 2010-11-24

topfs2 Wrote:Any more feature requests for version 4? Any questions?

Hi Tobias,

considering this List following request is not yet implemented:

I find it very usefull to know what the xbmc-user is currently doing. e.g. Is he in the music menu? Which album has he selected.
With this knowledge it should be possible to visualize a smaller UI on LCD displays with other libraries but LCDproc, or even a webpage, but the normal remote control is still the input device.


- Montellese - 2010-11-24

staeff Wrote:I find it very usefull to know what the xbmc-user is currently doing. e.g. Is he in the music menu? Which album has he selected.
With this knowledge it should be possible to visualize a smaller UI on LCD displays with other libraries but LCDproc, or even a webpage, but the normal remote control is still the input device.

This is what I currently do using the System.CurrentControl and System.CurrentWindow InfoLabels. I know it's an ugly hack and you have to perdiodically poll the information (doing it every 500ms right now) but it works pretty well (apart from the XBMC crashes I mentioned above).

I would love to see some support for this using Announcements and I'd be willing to look into the code to do it myself but currently I have absolutely no time at all Blush


- blinkseb - 2010-11-24

Montellese Wrote:...

I also have an idea why this might be happening: In my application I have an option to enable polling XBMCs CurrentControl info label every 500 ms. This allows to display the label of the current control on the LCD display and therefore it is possible to use XBMC without turning on the TV. BUT on shutdown it might happen that a GetInfoLabels() call is sent right before/after the ApplicationStop announcement arrived. Now XBMC is already shutting down its webserver but receives another request and might not know what to do.

I want to emphasize that this is only an idea I had because I noticed that everytime XBMC crashes on shutdown I get errors in the log of my application and when it doesn't crash there are no errors either.

I'll see if I can get rid of the calls causing the problem but if it is really as I suspect XBMC shouldn't really crash just because there is some stupid application (which might not listen to the announcements) calls another JSON RPC method when XBMC doesn't expect it.

Indeed, XBMC should not crash at all, even with bad applications. I'll look at it right now.


- Montellese - 2010-11-24

If you need any more informations I'll be happy to provide whatever I can.

I played around with my application and optimized it a bit and now it doesn't happen frequently but it still happens. And everytime it happens I get an error in the log of my application that the HTTP request to XBMC failed because it timed out. If XBMC doesn't crash there is no error visible so there must be a connection between the two.

I'll try to get read of it completely but the problem would still exist with applications which simply don't listen to the announcements and continue sending JSON RPC calls to XBMC until they get no response anymore. My application listens to the Announcements but as they are not foreseeable it can still happen that it sends a call right before the announcement arrives.


- blinkseb - 2010-11-24

Montellese Wrote:If you need any more informations I'll be happy to provide whatever I can.

I played around with my application and optimized it a bit and now it doesn't happen frequently but it still happens. And everytime it happens I get an error in the log of my application that the HTTP request to XBMC failed because it timed out. If XBMC doesn't crash there is no error visible so there must be a connection between the two.

I'll try to get read of it completely but the problem would still exist with applications which simply don't listen to the announcements and continue sending JSON RPC calls to XBMC until they get no response anymore. My application listens to the Announcements but as they are not foreseeable it can still happen that it sends a call right before the announcement arrives.

I'll try to spam XBMC with json request every 100ms until it crashes Smile I think it's because the json message is handled between the moment xbmc starts to shutdown and the moment it's actually shutdown. Some object may already be deleted -> crash.


- Montellese - 2010-11-24

Two more minor information details I can provide:

When it crashes and I tell Windows to start the JIT-Debugger it says:
Code:
An unhandled Win32 exception occured [3700]

And when I start the JIT-Debugger XBMC closes and the Debugger-Output says:
Code:
The program '[3700] XBMC.exe: Native' has exited with code -1073740777 (0xc0000417).

Not sure if this can be of any help. A short google search didn't turn up anything useful on the exit code.


- blinkseb - 2010-11-24

Montellese Wrote:Two more minor information details I can provide:

When it crashes and I tell Windows to start the JIT-Debugger it says:
Code:
An unhandled Win32 exception occured [3700]

And when I start the JIT-Debugger XBMC closes and the Debugger-Output says:
Code:
The program '[3700] XBMC.exe: Native' has exited with code -1073740777 (0xc0000417).

Not sure if this can be of any help. A short google search didn't turn up anything useful on the exit code.

I was able to make it crash very easily Wink It's fixed in r35448 (http://trac.xbmc.org/changeset/35448)

Thanks for the report!


- Montellese - 2010-11-24

blinkseb Wrote:I was able to make it crash very easily Wink It's fixed in r35448 (http://trac.xbmc.org/changeset/35448)

Thanks for the report!

Glad to here that. Ah I see the list of all the info labels was already deleted and then JSON RPC tried to access an index in that list which didn't exist anymore.

I'm glad I noticed it before you released Dharma stable Big Grin


Question about one of the new additions to XBMC JSON... - giftie - 2010-11-25

I'm trying to use JSON in my script to get around a problem that I have with the different DBs that people use(I don't have a problem about SQLite, just MySQL)

I see one of the new additions is GetAlbumDetails.

I hope I am structuring the call correctly. I'm not sure which way is the right one.
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbumDetails", "param": {"albumid": "2"}, "id": 1}

or is this correct?

Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbumDetails", "param": {"albumid": 2}, "id": 1}