You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Grace <qi...@gmail.com> on 2011/12/20 12:09:32 UTC

How to config the rpc to a remote Shindig server

While using the common container, we always use the following line:

                   var cfg = {},

            cfg[osapi.container.ServiceConfig.API_PATH] = CONTEXT_ROOT +
"/rpc";
            var cc = new osapi.container.Container(cfg);

If we deploy Shindig on server 1(on port 8080), and the application on
server 2(on port 8081). How to config the service api path.

If I config it to a absolute url , such as "http://localhost:8080/cre/rpc",
then the final request will send to
"http://localhost:8081http//localhost:8080/cre/rpc?st=john.doe%3Ajohn.doe%3Aappid%3Acont%3Aurl%3A0%3Adefault",
while the right url should be "
http://localhost:8081/proxy?url=http//localhost:8080/cre/rpc?st=john.doe%3Ajohn.doe%3Aappid%3Acont%3Aurl%3A0%3Adefault
".

Anyone know how to config it? Thanks!

Re: How to config the rpc to a remote Shindig server

Posted by Henry Saputra <he...@gmail.com>.
Looks like it needs code fix. Maybe we could use the client side
shindig.uri feature to construct the right URL

- Henry

On Mon, Feb 6, 2012 at 3:09 PM, Li Xu <le...@gmail.com> wrote:
> Stanton,
> Doesn't seem like it can workaround without a fix this time...Here's what I
> think how we may fix this:
>
> cfg[osapi.container.ServiceConfig.PROXY_URI]  = "http://localhost:8181/proxy
> ";
> cfg[osapi.container.ServiceConfig.API_HOST] = "http://localhost:8080/cre";
> cfg[osapi.container.ServiceConfig.API_PATH] = "rpc";
>
> When adding the st information in jsonrpctransport.js:
> url +="?st=";   ==> this would be API_HOST+API_PATH+"?st"
> url += encodeURIComponent(token);
>
> now we need to check if proxy url is available and shindig API_HOST is a
> cross domain url for current site,
> it would have to encode the whole url portion in above example, then append
> it back as a url parameter to proxy url like...
>
> any comments?
>
> thanks,
> li

Re: How to config the rpc to a remote Shindig server

Posted by Li Xu <le...@gmail.com>.
Stanton,
Doesn't seem like it can workaround without a fix this time...Here's what I
think how we may fix this:

cfg[osapi.container.ServiceConfig.PROXY_URI]  = "http://localhost:8181/proxy
";
cfg[osapi.container.ServiceConfig.API_HOST] = "http://localhost:8080/cre";
cfg[osapi.container.ServiceConfig.API_PATH] = "rpc";

When adding the st information in jsonrpctransport.js:
url +="?st=";   ==> this would be API_HOST+API_PATH+"?st"
url += encodeURIComponent(token);

now we need to check if proxy url is available and shindig API_HOST is a
cross domain url for current site,
it would have to encode the whole url portion in above example, then append
it back as a url parameter to proxy url like...

any comments?

thanks,
li

Re: How to config the rpc to a remote Shindig server

Posted by Grace <qi...@gmail.com>.
Thanks Stanton, It can work basically. But I found another problem with an
encode issue, as the endpoint is simply plus the host and path. For
example:
cfg[osapi.container.ServiceConfig.API_HOST] = "
http://localhost:8081/proxy?url=http//localhost:8080/cre/"
cfg[osapi.container.ServiceConfig.API_PATH] = "rpc"

Then the endpoint is :
http://localhost:8081/proxy?url=http//localhost:8080/cre/rpc

When adding the st information in jsonrpctransport.js:
url +="?st=";
url += encodeURIComponent(token)

Then the url become:
http://localhost:8081/proxy?url=http//localhost:8080/cre/rpc?st=
john.doe%3Ajohn.doe%3Aappid%3Acont%3Aurl%3A0%3Adefault

While it's wrong, there isn't any place to encode the whole url, the right
one should be :

http://localhost:8081/proxy?url=<http://localhost:8081/proxy?url=http//localhost:8080/cre/>
http%2F%2Flocalhost%3A8080%2Fcre%2Frpc%3Fst%3Djohn.doe%253Ajohn.doe%253Aappid%253Acont%253Aurl%253A0%253Adefault%20

So the core issue is that is there a place to indicate a proxy for the rpc
request.

On Tue, Dec 20, 2011 at 8:29 PM, Stanton Sievers <ss...@us.ibm.com>wrote:

> Hi Grace,
>
> You can also set osapi.container.ServiceConfig.API_HOST in your config
> object.
>
> For instance, in your example below you would set
> cfg[osapi.container.ServiceConfig.API_HOST] = "
> http://localhost:8081/proxy?url=http//localhost:8080/cre/"
>
> Then the API_PATH will be concatenated to the end of that and should build
> the request as you outlined below.
>
> Best regards,
> -Stanton
>
>
>
> From:   Grace <qi...@gmail.com>
> To:     dev@shindig.apache.org,
> Date:   12/20/2011 06:09
> Subject:        How to config the rpc to a remote Shindig server
>
>
>
> While using the common container, we always use the following line:
>
>                   var cfg = {},
>
>            cfg[osapi.container.ServiceConfig.API_PATH] = CONTEXT_ROOT +
> "/rpc";
>            var cc = new osapi.container.Container(cfg);
>
> If we deploy Shindig on server 1(on port 8080), and the application on
> server 2(on port 8081). How to config the service api path.
>
> If I config it to a absolute url , such as "http://localhost:8080/cre/rpc
> ",
> then the final request will send to
> "
> http://localhost:8081http
> //localhost:8080/cre/rpc?st=john.doe%3Ajohn.doe%3Aappid%3Acont%3Aurl%3A0%3Adefault
> ",
> while the right url should be "
>
> http://localhost:8081/proxy?url=http//localhost:8080/cre/rpc?st=john.doe%3Ajohn.doe%3Aappid%3Acont%3Aurl%3A0%3Adefault
>
> ".
>
> Anyone know how to config it? Thanks!
>
>
>
>

Re: How to config the rpc to a remote Shindig server

Posted by Stanton Sievers <ss...@us.ibm.com>.
Hi Grace,

You can also set osapi.container.ServiceConfig.API_HOST in your config 
object.

For instance, in your example below you would set 
cfg[osapi.container.ServiceConfig.API_HOST] = "
http://localhost:8081/proxy?url=http//localhost:8080/cre/"

Then the API_PATH will be concatenated to the end of that and should build 
the request as you outlined below.

Best regards,
-Stanton



From:   Grace <qi...@gmail.com>
To:     dev@shindig.apache.org, 
Date:   12/20/2011 06:09
Subject:        How to config the rpc to a remote Shindig server



While using the common container, we always use the following line:

                   var cfg = {},

            cfg[osapi.container.ServiceConfig.API_PATH] = CONTEXT_ROOT +
"/rpc";
            var cc = new osapi.container.Container(cfg);

If we deploy Shindig on server 1(on port 8080), and the application on
server 2(on port 8081). How to config the service api path.

If I config it to a absolute url , such as "http://localhost:8080/cre/rpc
",
then the final request will send to
"
http://localhost:8081http//localhost:8080/cre/rpc?st=john.doe%3Ajohn.doe%3Aappid%3Acont%3Aurl%3A0%3Adefault
",
while the right url should be "
http://localhost:8081/proxy?url=http//localhost:8080/cre/rpc?st=john.doe%3Ajohn.doe%3Aappid%3Acont%3Aurl%3A0%3Adefault

".

Anyone know how to config it? Thanks!