Search code examples
restjax-rshttp-status-code-401payara

401 UnAuthorized - This request requires HTTP authentication - Payara/Glassfish


Initial Context:

We're developing Web Aplication Server and deploying it in Payara Server 4.1.2.173. The mininal stability testing are passing perfect and MVP works perfectly but in order to improve the performance testing of the system we have created different test case in JMeter (3.2) that simulates Front-End normal activity and make all the necessary requests to the server.

The problem:

When JMeter starts making request REST(JAX-RS) everything works fine but suddenly some requests (users) return the following error response:

    <h1>HTTP Status 401 - Unauthorized</h1>
    <hr/>
    <p>
        <b>type</b> Status report</p><p>
        <b>message</b>Unauthorized</p><p>
        <b>description</b>This request requires HTTP authentication.</p>
    <hr/>

It's very strange because the error appears randomly and apparently it is not because of concurrency problems.

Any ideas what might be the issue? Thanks


Solution

  • After a few research I've discovered that JMeter has some difficulties to add dynamic header token to Http request when volume Thread request are increasing. In my scenario I was doing the following:

    1. Making a HTTP Login request
    2. Generating token session in Server
    3. JMeter gives the token from the response and I apply post-processor to encode it to Base64 and save to JMeter system variables.
    4. In the next HTTP request I add the token in HTTP Header configuration component as a Basic Authorization.

    When the amount of Threads increase (150 approx) Server return error 401. Despite of JMeter shows as if the token are included in header, there is no sign of it in the real request. The behaviour appears randomly and with no common reason...

    Solution:

    We have decided to add token session as a part of CSV Data set - configuration file and JMeter is capable of manage all requests without any rare 401 error.