How to check user token limits? - limit

How to check user token limits?
and why, when the maximum number of queries, requests continue to send?
Maximal limit is 5000 requests.

The response header for Instagram API has information on API limit and how much has been used.
Look for X-Ratelimit-Remaining and X-Ratelimit-Limit
Cache-Control:private, no-cache, no-store, must-revalidate
Connection:keep-alive
Content-Encoding:gzip
Content-Language:en
Content-Length:10117
Content-Type:application/json; charset=utf-8
Date:Thu, 20 Mar 2014 17:18:46 GMT
Expires:Sat, 01 Jan 2000 00:00:00 GMT
Pragma:no-cache
Server:nginx
Max-Age=31449600; Path=/
Vary:Cookie, Accept-Language, Accept-Encoding
X-Ratelimit-Limit:5000
X-Ratelimit-Remaining:4995
If you exceed the limit then you will get a HTTP 400 response, with a JSON response that has error_message that API limit has exceeded.

The API documentations says:
Be nice. If you're sending too many requests too quickly, we'll send
back a 503 error code (server unavailable).
So I guess you should look for a 503 as your indication that you've hit the limit. I haven't actually verified that this is the case, but it appears they have an Apigee front end, so I suspect it would work as stated.

Related

Response code: 400 Bad Request Error in Jmeter 4.0. Need assistance in fixing this error

I am using JMeter 4.0 for recording & running performance tests. I am also fairly new to this tool and for the 1st time, I'm getting Error 400 Bad request for which all the tests are failing. I am recording a website through VPN & trying it to run the test the same way as I did before.
Can you please help me with this. I can provide additional screenshots and details as & when you say required.
Sampler Result:
Thread Name: Converse_Chat_No 1-1
Sample Start: 2018-06-06 14:29:19 IST
Load time: 1313
Connect Time: 1104
Latency: 1313
Size in bytes: 1639
Sent bytes:1982
Headers size in bytes: 554
Body size in bytes: 1085
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 400
Response message: Bad Request
Response headers:
HTTP/1.1 400 Bad Request
Date: Wed, 06 Jun 2018 08:59:22 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1085
Connection: keep-alive
Set-Cookie: AWSALB=hCxbUY5Kq+Vdfv1jhO/JGeLqCqRHT281vZy+T4LFgJCRnItYwGILJLnD3KPsv5wYlVGiy85bYqVH75PSlLNCLcPPDTDtgGHoXAKbw9T8QoT6WPxPm6qVI4tyG7H1; Expires=Wed, 13 Jun 2018 08:59:22 GMT; Path=/
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'self'
X-Content-Type-Options: nosniff
X-Powered-By: Express
HTTPSampleResult fields:
ContentType: text/html; charset=utf-8
DataEncoding: utf-8
As per 400 Bad Request description:
The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server could not understand the request due to invalid syntax.
The client should not repeat this request without modification.
So most probably you're sending malformed requests which server doesn't understand.
The only troubleshooting technique I can think of is recording requests which real browser sends using a sniffer tool like Fiddler or Wireshark and comparing them to what JMeter sends. The requests should be the same (apart from dynamic data which has to be correlated)
As soon as you amend your JMeter test plan to 100% match requests which are being sent by the real browser it should start working. Don't forget about Cookies and Headers.

JMETER 403 when uploading a file but needs to be logged in

So I am trying to test the file upload function of this website: http://the-v.net/en/vtube/upload-video through JMETER but to be successful, the user has to be logged in through this form: http://the-v.net/login, Now, I think this is a parameter-based authentication which could be solved by defining a valid username and password in the HTTP Authorization Manager config element, but even doing so I keep getting this error:
Thread Name: Thread Group 1-1
Sample Start: 2018-01-30 20:11:06 CST
Load time: 1373
Connect Time: 214
Latency: 1167
Size in bytes: 19151
Sent bytes:134
Headers size in bytes: 768
Body size in bytes: 18383
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 403
Response message: Forbidden
Response headers:
HTTP/1.1 403 Forbidden
Date: Tue, 30 Jan 2018 12:11:06 GMT
Server: Apache/2.4.23 (Win64) PHP/5.6.25
X-Powered-By: PHP/5.6.25
X-Drupal-Cache: MISS
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: public, max-age=900
X-Content-Type-Options: nosniff
Content-Language: en
X-Frame-Options: SAMEORIGIN
X-Generator: Drupal 7 (http://drupal.org)
Link: <http://the-v.net/en/vtube/warning>; rel="canonical",<http://the-v.net/en/vtube/warning>; rel="shortlink",<http://the-v.net/sites/all/themes/vtube17/favicon.png>; rel="shortcut icon"
Etag: "1517314266-0"
Last-Modified: Tue, 30 Jan 2018 12:11:06 GMT
Vary: Cookie,Accept-Encoding
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
HTTPSampleResult fields:
ContentType: text/html; charset=utf-8
DataEncoding: utf-8
Any idea on how can I solve this? Thanks
I would suggest you record the upload in the browser and look in View Results Tree the headers/ coookies that are transmitted.
You can use File > Template. > Recording
Read:
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html
You are most probably missing:
A header
A cookie
A parameter
You need to be logged in in order to be able to upload anything. HTTP Authorization Manager won't help as it is designed to deal with protocol level authentication and you need cookie-based one.
Add HTTP Cookie Manager to your Test Plan
Pay attention to form_build_id dynamic parameter you need to pass along with credentials during login request
So your test plan should look like:
1st HTTP Request - open login page
Post-Processor (i.e. CSS/JQuery Extractor to fetch form_build_id
2nd HTTP Request - perform login - provide credentials and the form_build_id from the previous step. You will also need to pass form_id parameter with the value of MYFORM_form
3rd HTTP Request - perform the upload.

Cloudfront - why is this not being "browser cached"?

Here's the curl -I response to my Javascript file:
HTTP/1.1 200 OK
Content-Type: text/javascript
Content-Length: 72640
Connection: keep-alive
Date: Sat, 18 Feb 2017 16:12:06 GMT
Cache-Control: 86400
Last-Modified: Wed, 15 Feb 2017 15:09:28 GMT
ETag: "a6ee06ff5e49a4290bb2aabe5e0f9029"
Server: AmazonS3
Vary: Accept-Encoding
Age: 1173
X-Cache: Hit from cloudfront
Via: 1.1 3b17302562f1709d8b6c9f7be1.cloudfront.net (CloudFront)
I can see the Cache-Control tag there. Not sure what the Vary and the ETag are doing, but so be it. Does this somehow specify to a user's browser NOT to cache this file? Why are Pingdom or Goog PageSpeed not recognising this as a browser-cacheable file?
Your Cache-Control header is present, but the value is not actually valid. The correct format looks like this:
Cache-Control: max-age=86400
The number, by itself, is meaningless.
ETag: is the entity tag -- an opaque value that uniquely identifies the current content of a given URL. If the content changes, the ETag will also change. A browser with a cached copy may use this value for subsequent requests to ask that the server only return the content if it differs, by sending an If-None-Match: request header, including the last-seen ETag.
Vary: tells the browser that certain changes to the request may generate a different response. Unlike browsers, curl doesn't advertise its ability to support gzipped payload unless you specify the --compressed option. Adding that option when invoking curl triggers the addition of Accept-Encoding: gzip to the request, which may trigger the response to be compressed if you have that option enabled in CloudFront.

When serving a response cached by the server, IIS 7 is stripping the Vary header

I’m using a custom framework for bundling stylesheets and scripts. (I.e., these are dynamically generated responses, not static files.)
The response for the initial request, when the response is being generated for the very first time, includes these headers:
HTTP/1.1 200 OK
Cache-Control: public, no-transform, max-age=31536000
Content-Type: text/css; charset=utf-8
Content-Encoding: gzip
Last-Modified: Mon, 25 Aug 2014 18:15:50 GMT
Vary: Accept-Encoding
Date: Tue, 09 Sep 2014 16:19:36 GMT
Content-Length: 3126
Now that the response above has been generated and cached by the server, subsequent requests for the same stylesheet are responded to with these headers:
HTTP/1.1 200 OK
Cache-Control: public, no-transform, max-age=31536000
Content-Type: text/css; charset=utf-8
Content-Encoding: gzip
Last-Modified: Mon, 25 Aug 2014 18:15:50 GMT
Date: Tue, 09 Sep 2014 16:20:00 GMT
Content-Length: 3126
Ignoring the new Date value, the headers are identical with the obvious exception of the missing Vary header.
One nasty consequence that I’ve seen in the wild is that if the very first response generated for a given asset is not compressed (due to the corresponding client not supporting compression), then the server caches that non-compressed response and serves it for all subsequent requests to all clients.
Any idea how to have the server retain the Vary header for cached responses?
I’m using HttpCacheability.Public for these responses. I can avoid the issue by using HttpCacheability.Private instead, but I’d prefer to allow the server and proxies to cache responses.
Some reading has led me to believe that IIS can’t do “kernel caching” if you vary by encoding. But I’m not sure if that means I can’t cache on the server at all or if it just prevents a special kind of server-side caching.
Update:
I was originally using the following to set the Vary header:
response.AppendHeader("Vary", "Accept-Encoding");
I tried a different method of specifying it:
response.Cache.SetVaryByCustom("Accept-Encoding");
That caused Vary to never be emitted. Not even on the very first response.
As a last resort, I’m also considering using:
response.Cache.SetNoServerCaching();
That causes the Cache-Control header to still specify public (so that proxies can still cache), but prevents the server from caching.
In line with the update I made to the question, I tried yet another way of specifying the Vary header:
response.Cache.VaryByHeaders["Accept-Encoding"] = true;
…And it fixed the problem. Responses now retain the Vary header across requests from multiple clients and are also cached by the server.

What is wrong with this OAuth request to the Pocket API?

I'm trying to build a simple script using the Pocket API and I'm getting a 400 bad request when following the documentation on the site. Here is what I get:
POST /v3/oauth/request?consumer_key=xxxxxx-
xxxxxxxxxxxxxxxxxxx&redirect_uri=http://localhost:3000/callback HTTP/1.1
Host: getpocket.com
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
I am using Postman and I am running the redirect_uri from the rails server.
Additional information:
Cache-Control →private
Connection →keep-alive
Content-Length →15
Content-Type →text/html; charset=UTF-8
Date →Mon, 21 Apr 2014 01:17:05 GMT
Expires →Thu, 19 Nov 1981 08:52:00 GMT
P3P →policyref="/w3c/p3p.xml", CP="ALL CURa ADMa DEVa OUR IND UNI COM NAV INT STA PRE"
Pragma →no-cache
Server →Apache
Status →400 Bad Request
X-Error →Missing consumer key.
X-Error-Code →138
X-Source →Pocket
In a search to find out which x-error code was giving me a 400, I found that it's giving me a missing consumer key. I'm at a loss since this is a brand new key and I am certainly using it correctly. Any thoughts?
You are sending the consumer_key and redirect_uri as url parameters ?consumer_key=xxxxxx..
The correct way is to send them as form-data parameters:

Resources