Git Product home page Git Product logo

Comments (7)

ashishgupta-okta avatar ashishgupta-okta commented on August 19, 2024

@bvbsdvy I have been able to reproduce it consistently and I also have tested with multiple scenarios. There are sure many ways to fix it. When the server closes the connection, only the next client request fails because the client is not aware of the close, so retrying the request will work as it will create a new connection in the retry request. The root cause lies in the Apache HTTPClient and not our code. Section 2.5 here explains that: https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html. As I understand it is "not 100%" reliability of the http client to detect stale connections.

To reproduce the issue , you can make 200 requests in a loop with a delay of 6secs. The TTL on our server is 5 seconds. I have consistently been able to reproduce the issue using this.

from okta-sdk-java.

ashishgupta-okta avatar ashishgupta-okta commented on August 19, 2024

Also , this issue is not just with AuthApiClient , this issue happens with any API if we use the Apache HTTPClient.

from okta-sdk-java.

 avatar commented on August 19, 2024

I was not able to reproduce it with the following code. All 200 tries were successful:

public void testOkta() throws Exception {
    ApiClientConfiguration config = new ApiClientConfiguration(oktaUrl, oktaApiKey);
    AuthApiClient apiClient = new AuthApiClient(config);

    for (int i = 0; i < 200; i++) {
        AuthResult result = apiClient.authenticate(username, password, "");
        System.out.println(i + ". " + result.getStatus());
        Thread.sleep(6000);
    }
}

(oktaUrl, oktaApiKey, username, and password are just Strings defined in my test class.)

I tried one run using HttpClient 4.5.2 with HttpCore 4.4.4 -- these are the latest versions of the Apache libraries currently. I also tried a second run using the default versions that are dependencies of the Okta SDK: HttpClient 4.3.6.

The version of Okta SDK I'm using is 874dcfd.

from okta-sdk-java.

ashishgupta-okta avatar ashishgupta-okta commented on August 19, 2024

The behaviour is very random. Try this

for(int i = 0 ; i < 500; i++) {
List users = usersClient.getUsersWithQuery(Integer.toString(random.nextInt()));
Thread.sleep(6000);
System.out.println(i);
User newUser = usersClient.createUser(
"First",
"Last",
"login" + Integer.toString(random.nextInt()) + "@example.com",
"email" + Integer.toString(random.nextInt()) + "@example.com",
true);

        List<UserGroup> userGroups = userGroupApiClient.getUserGroupsWithLimit(1);

        // Read
        User user = usersClient.getUser(newUser.getId());
        Assert.assertTrue(newUser.getId().equals(user.getId()));

        // Update
        user.getProfile().setLastName("NewLast");
        user = usersClient.updateUser(user);

        usersClient.setRecoveryQuestion(newUser.getId(), "how are you", "winter is coming");

        UserGroup group = new UserGroup();
        group.setId(Integer.toString(random.nextInt()));
        UserGroupProfile profile = new UserGroupProfile();
        profile.setName(Integer.toString(random.nextInt()));
        group.setProfile(profile);

        group = userGroupApiClient.createUserGroup(group);

        userGroupApiClient.addUserToGroup(group.getId(), newUser.getId());
    }

from okta-sdk-java.

lboyette-okta avatar lboyette-okta commented on August 19, 2024

This should be fixed by #23

from okta-sdk-java.

ggehlot avatar ggehlot commented on August 19, 2024

@lboyette-okta In the commit, I see that you are using StandardHttpRequestRetryHandler to fix this issue. But AuthApiClient.authenticate method uses POST method which is not idempotent. But I think StandardHttpRequestRetryHandler only retries idempotent methods. So that excludes POST which is used in this method. Can you please explain how the fix works in this case?

from okta-sdk-java.

lboyette-okta avatar lboyette-okta commented on August 19, 2024

@ggehlot You're correct that StandardHttpRequestRetryHandler doesn't cover that case, so the current fix won't work for the AuthApiClient (or for any methods that require POST).

from okta-sdk-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.