Re: JSON (1707 Views)
Reply
Advisor
jramz
Posts: 25
Registered: ‎08-30-2011
Message 1 of 6 (1,729 Views)

JSON

Hi all,

 

Anyone have experience witih JSON (Javascript Open Notattion)?

 

Please see attached.  I am trying to understand a data field in the POST method called "Name=__o3fmeta" which seems to contain JSON.  The value is enormous...if I keep this field in my script, upon playback, the IBM HTTP Server throws the following error message:

 

**********************************************************************************
Request-URI Too Large
 
The requested URL's length exceeds the capacity limit for the server.
 
IBM_HTTP_Server at xxxxxxxxxxxxxxxxxx
**********************************************************************************

 

But, normal users don't experience this - so, LoadRunner seems to have an issue with the JSON.

 

Any insight on how to handle JSON would be appreciated.

 

Regards,



joe

Trusted Contributor
Oliver Lloyd
Posts: 218
Registered: ‎03-12-2009
Message 2 of 6 (1,707 Views)

Re: JSON

JSON is a format for sending data, like XML. It's just text, LoadRunner can handle it. The only specific issue LR does have with json is that 2 of the reserved characters used by the json format are { and } and the problem here is that LR also has these as reserved chars so you can get into a mess. The solution is either:

 

1. Change the default parameter delimeter character (off the top of my head: general options?).

2.Correlate the whole json string and manipulate the string using C code before sending the whole thing back to the server as one big parameter.

3. Data Format Extentions (new in LR11) - I've seen this pop up before as a suggestion to dealing with json but I can't speak for it.

 

BUT I'm not sure how that would give you the error you are getting here.

 

Man, that is a crazy post, you're going to have fun ith this.

 

OK, so, things to note:

 

1. You're not actually sending any LR params inside the json string so my point above is moot - still worth noting though.

2. Inside the json string there are, however, a bunch of url params like '__o3id24' - this is getting set as a URL value= param - yu can see them all being set at the top of your request. In this case __o3id24 = ITYN4002. But inside the json string it sending the url param name, and not it's value - this is a bit odd. Either this is correct (and the server handles this) or you need to sustitute the variable names (__o3id24) for their values.

 

You can check this easily enough and this is the first thing you should do: In a broswer iike Chrome use Developer Tools (Firebug in Firefox) to capture the same post. Then you can look at what is being sent normally and compare it with what is in the LoadRunner script. This is the best way to debug this problem.

 

Once you've done that you should go and find the developer that did this and ask him to explain it. Ask him why the post is sending the same data twice, once as a dizzying number of URL params and then sticking another URL param on the end sending a json string with all the same data in. And then ask them why on earth this POST is sending the text of the questions BACK to the server in this json string? They should be sent from the server to the client when it loads the page - you don't need to send them back again!

 

If in Chrome you can see that different requests are being made then you need to rerecord. Try URL mode. The trick is to make the requests sent by LR match - exactly - those sent by the application manually.

 

Oh, and the nocache value should probably be parametised with a unix timestampt to stop caching.

 

Good luck.

 

You know, if all your posts look like this and if this is an internal application with low concurrency, then maybe something like TruClient might be wise?

Oliver
Advisor
jramz
Posts: 25
Registered: ‎08-30-2011
Message 3 of 6 (1,705 Views)

Re: JSON

Oliver,

 

Thanks for the reply...very good suggestions.  I do have a meeting with the developers to figure this one out....

 

A strange one.

 

We are upgrading to 11.0, so we may be able to take advantage of the data format extensions (there is one for JSON)...and may try TruCLient.

 

Thanks again for your response.

 

-joe

Advisor
jramz
Posts: 25
Registered: ‎08-30-2011
Message 4 of 6 (1,693 Views)

Re: JSON

Oliver,

 

One more question.  You metioned the nocache value.  The Actions section of my script is close to 3,000 lines...and this nocache is everywhere.  I guess I could create a correlation rule.  But what is the nocache...I mean, what purpose does it server...and could I potentially ignore it?

 

Thanks,

 

joe

 

Trusted Contributor
Oliver Lloyd
Posts: 218
Registered: ‎03-12-2009
Message 5 of 6 (1,687 Views)

Re: JSON

nocache is simply a string that changes every time the request is sent - it is designed to prevent caching by things like CDNs. If the URL is different then cache logic will not kick in and the request will go back to origin, where it is meant to. It can often be redundant but it's very simple to parametise - it is just a unix timestamp value (number of seconds since Jan 1st, 1970 - currently: 1318965245) there should be an option in LR to format a param like this (if not someone should be fired!).

 

3000 lines? Boy oh boy, that does not sound fun. You really need to be aware that scripts like this are going to cost a lot of time to setup and maintain - it's far from impossible, totally doable, but the initial curve will be steep and then whenever you have code changes you will probably need to rerecord. At the very least, you should make sure you are focusing on only the critical paths through your app - keep it simple. Watch out for memory issues too, you'll need to monitor you LGs very closely.

Oliver
Advisor
jramz
Posts: 25
Registered: ‎08-30-2011
Message 6 of 6 (1,658 Views)

Re: JSON

Hi Oliver,

 

One more thing regarding the nocache value.

 

The value (below) in red is actualy the number of seconds since January 1, 1970 (Unix/POSIX time) & is generated on the browser side.  I have no idea what the value in blue is...would you have any idea?  

 

nocache=1317314080255_0
 

Thanks again,

 

joe

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.