JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC

  Thread Rating:
  • 7 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
sjroesink Offline
Junior Member
Posts: 4
Joined: May 2012
Reputation: 0
Post: #1901
Thanks for the fast response.
I did try other methods. They all give the same parse error.

Is there any way I can provide more information to make the debugging easier? I'm not sure how to debug websockets.
find quote
Montellese Offline
Team-XBMC Developer
Posts: 2,776
Joined: Jan 2009
Reputation: 20
Location: Switzerland
Post: #1902
Neither am I. I just ran latest XBMC (from master not a nightly build, but shouldn't make a difference) and used the websocket demo on websocket.org, opened a websocket to XBMC and ran JSONRPC.Ping, JSONRPC.Version and VideoLibrary.GetMovies without a problem.

EDIT: What browser are you using and are you using any framework for websockets?

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
(This post was last modified: 2012-05-06 11:15 by Montellese.)
find quote
sjroesink Offline
Junior Member
Posts: 4
Joined: May 2012
Reputation: 0
Post: #1903
When using Firefox, I can't get the websocket.org demo to connect to the websocket. In Chrome I can.

Via the demo I found out I had to send the JSON encoded string instead of the actual object (I tried this before using the Introspect method, but this gave me the error "Received unexpected continuation frame."):
Code:
var xbmcSocket = new WebSocket('ws://localhost:9090/jsonrpc');
xbmcSocket.onopen = function() {
    console.log('xbmcSocket.open');
    xbmcSocket.send(JSON.stringify({
        "id": 1,
        "jsonrpc": "2.0",
        "method": "JSONRPC.Ping"
    }));
};
xbmcSocket.onmessage = function(msg) {
    console.log('xbmcSocket.onmessage', msg);
};

This does work!

BTW: The error "Received unexpected continuation frame." also occurs when I start playing a movie.
find quote
Mizaki Offline
Fan
Posts: 662
Joined: Apr 2011
Reputation: 12
Post: #1904
That's funny. I was just about to post I was having problems. I've been trying on and off for a few days, I'm doing basically the same thing but I don't get a connection. It tries to open and then after a while I get a closed message and error "Firefox can't establish a connection to the server at ws://10.0.0.101:9090/jsonrpc". Here is the simple code:
Code:
        wsListener: function() {
            if ("WebSocket" in window) {
                
                var wsConn = 'ws://' + location.hostname + ':9090/jsonrpc';
                console.log(wsConn);
                var ws = new WebSocket(wsConn);
                console.log(ws);
                ws.onopen = function (e) {
                    console.log('socket open');
                    ws.send('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties" : ["thumbnail"]}, "id": 1}');
                };
                ws.onerror = function (err) {
                    console.log(err);
                };
                ws.onmessage = function (e) {
                    console.log(e.data);
                };
                ws.onclose = function (e) {
                    console.log('socket close');
                };
            };
        }
I can't see what I'm doing wrong. Seems rather simple... I've allowed everything in network just in case. Any ideas? I've tried FF and Chrome.

EDIT: Just thought I'd try the websocket.org demo. Works in Chrome but not in FF. Error in log:
Code:
10:39:44 T:2874841968    INFO: WebSocket [RFC6455]: invalid "connection" received
10:39:44 T:2874841968    INFO: WebSocket: No frame expected in the current state

EDIT, EDIT: Okay and now Chrome is working fine. Maybe because I just allowed UPnP access?

I'll leave all this here for any searchers it might help.

[Image: watched-clearlogo.jpg]
AWXi - Ajax web interface. Wiki
(This post was last modified: 2012-05-06 11:45 by Mizaki.)
find quote
Montellese Offline
Team-XBMC Developer
Posts: 2,776
Joined: Jan 2009
Reputation: 20
Location: Switzerland
Post: #1905
Ah right I thought the websocket send method would take care of the stringification of the JSON object. Yes a websocket is just an extended TCP socket so you'll need to pass in everything as a string.

Back when I implemented this there was no browser who supported the final RFC6455 implementation yet so I could only test against the latest draft. Maybe there's a bug in there.

The only thing you should have to enable in the settings is "Allow programs on this system to control XBMC" (and "Allow programs on other systems to control XBMC" if that's what you want)).

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
Mizaki Offline
Fan
Posts: 662
Joined: Apr 2011
Reputation: 12
Post: #1906
I've figured out where I went wrong. When turning on the remote control option you have to exit XBMC and restart for it to take effect. Switching off works without a restart. This is for "other systems", I don't know about local.

[Image: watched-clearlogo.jpg]
AWXi - Ajax web interface. Wiki
find quote
Mizaki Offline
Fan
Posts: 662
Joined: Apr 2011
Reputation: 12
Post: #1907
To confirm all Player.OnPlay give the error:
Code:
Received unexpected continuation frame.
and closes the socket.

[Image: watched-clearlogo.jpg]
AWXi - Ajax web interface. Wiki
find quote
Mizaki Offline
Fan
Posts: 662
Joined: Apr 2011
Reputation: 12
Post: #1908
Question Sunday: Is there a reason why I can't request the "file" property for albums?

I do it with TV Shows to get the logo's and I'm thinking of seeing what I can do with the cdart files in case you want to know why.

[Image: watched-clearlogo.jpg]
AWXi - Ajax web interface. Wiki
find quote
Montellese Offline
Team-XBMC Developer
Posts: 2,776
Joined: Jan 2009
Reputation: 20
Location: Switzerland
Post: #1909
I'll have to look into both the "Received unexpected continuation frame" and the "other systems" setting not being available immediately after changing it. Could you please create bug tickets for these and CC me so I don't forget. Thanks.

IIRC the initial reasoning behind "file" not being available for albums (and artists) is because an album may be scattered over multiple directories so there's no "unique" path to the album. But the same reasoning could apply to tvshows. I guess a feature request can't hurt Wink

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 24,520
Joined: Oct 2003
Reputation: 138
Post: #1910
@Montellese: The same argument does apply to tvshows (which the db handles really badly - multiple ids for a show rather than multiple paths and a single id).

@Mizaki: I think the main problem here is you shouldn't need to assume anything about where images may or may not lie, and furthermore you shouldn't assume you have access to said potential images on the filesystem.

You may, however, assume that filesystem access can and will be shutdown come Frodo. Hopefully by then you won't need it for what you're doing Smile

Cheers,
Jonathan

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
Post Reply