Jump to content

What is the best way to send JSON between prims in two different Regions?


You are about to reply to a thread that has been inactive for 153 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I would like to send JSON messaging between two prims that are located in two different regions without having to reach out to an external webserver to do so. I have considered using a prim scripted with llHTTPRequest to contact another by key using XMLRPC scripting, but have read that XMLRPC is old school and replaced with llHTTPRequest.  What is the best way to do this using modern LSL techniques?

Link to post
Share on other sites

While you can request a URL for the receiving object(s) and send the JSON over HTTP, a region restart will remove the URL from the object, requiring you to request a new one which will be different.

If the whole grid goes down, or just both sims at the same time, you won't have any chance to communicate the new URL to the other object.

Without a static web server, you'll have to fix it by hand every time the regions go down. 

Edited by Wulfie Reanimator
Link to post
Share on other sites

... unless you happen to have control of the land settings on both sites, in which case you can use Key-Value Pair (KVP) persistent store as part of an Experience you enable at each location. Then, at a minimum, the HTTP-serving script can register its ephemeral URL as a value in that store (obviating the need for an external server). Or, depending what you're doing, you can replace the http messaging entirely with your own messaging protocol, writing into and polling from the KVP store directly. (That latter approach can be more efficient than the non-polling approach if the communication is a broadcast, so there are many more "readers" than "writers".)

Because you mention XMLRPC, of possible historical interest the really old-school way to do this was with llEmail, which is still exactly as viable as it always was: works great until SVC-23 bites, which the Lab has apparently given up on fixing for lack of reproducibility. Maybe in the cloud it'll just go away like coronavirus magic.

  • Thanks 1
Link to post
Share on other sites

Mad idea....not sure how well it would work or if it would work properly at all but...

if the data being sent doesn't need to be super secure, could you remotely modify a google doc such as a google sheet and then retrieve the information in the receiving prim. You should be able to modify and return a value. I am not sure how fast it would be but I did have a friend once who used that method to create a list of people who were banned on his scripted security system.

  • Like 1
Link to post
Share on other sites
36 minutes ago, ItHadToComeToThis said:

Mad idea....not sure how well it would work or if it would work properly at all but...

if the data being sent doesn't need to be super secure, could you remotely modify a google doc such as a google sheet and then retrieve the information in the receiving prim. You should be able to modify and return a value. I am not sure how fast it would be but I did have a friend once who used that method to create a list of people who were banned on his scripted security system.

This is an old trick that's still relatively common. I have friends who use it has an update system.

Link to post
Share on other sites

some ideas...

for the json..

  string j_obj = llList2Json( JSON_OBJECT,     
  [ "name", "test",
    "url", myURL  // or llUnescapeURL(myURL)
  ]);  

then you could send it as a get, post, response etc...

 llHTTPResponse(id, 200, j_obj);

if you use google apps scripts, your Code.gs script might look something like...

(if your url was stored in cell A2 , and the name of the sheet was ... "Data")

// to set
let url = "https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/edit#gid=0";
function doGet(e) {
  if ( e != "") { 
    var urlLink = e.parameter.txt; 
    let ss = SpreadsheetApp.openByUrl(url);
    let ws = ss.getSheetByName("Data"); 
    ws.getRange("A2").setValue(urlLink);

    return ContentService.createTextOutput("Url set")
      .setMimeType(ContentService.MimeType.TEXT);    
  }
};

// to get
let url = "https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/edit#gid=0";
function doGet(e) {
  if ( e != "") {  
  let ss = SpreadsheetApp.openByUrl(url);
  let ws = ss.getSheetByName("Data");   
  let resp = ws.getRange("A2").getValue(); 

    return ContentService.createTextOutput("url: " + resp)
     .setMimeType(ContentService.MimeType.TEXT);    
  }
};

assuming your send code was something like...

string URL = "https://script.google.com/macros/s/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/exec?txt=";

 http_request_id = llHTTPRequest(URL + myURL,
     [HTTP_METHOD, "GET", 
     HTTP_MIMETYPE, "text/plain",
     HTTP_BODY_MAXLENGTH,16384,
     HTTP_PRAGMA_NO_CACHE,TRUE], ""); 

and myURL was set with llRequestSecureURL(); ?

refernce vid for apps scripts: ...

 

Edited by Xiija
Link to post
Share on other sites

Try email to re-establish the URL connection if you suspect the HTTP server's region was restarted.  llGetNextEmail()/email event, and llEmail()/llTargetedEmail(). It's got a 20 second delay, and has odd failure modes documented, but it worked reasonably for me when I needed cross-region communication without resorting to outside services. I think I was checking for updates from the server hourly or daily, but certainly not frequently.

  • Like 1
Link to post
Share on other sites

One way that could work with the email thing (but well, it could break)

  1. Object A obtain HTTP url.
  2. Object B obtain HTTP url.
  3. Object A mail HTTP url to object B.
  4. Object B receive A's URL and confirms reception by sending on A's URL B's URL.
  5. Periodically have A and B check for the validity of they own url and the target URL.

You can probably do this in a fairly smart way and keep the actual emails to an absolute minimum.

HTTP gives us error codes and an opportunity to confirm message reception so you don't need to send emails unless HTTP failed.

Edited by Kyrah Abattoir
Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 153 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...