cancel
Showing results for 
Search instead for 
Did you mean: 

Web service session timeout

sylvain78
Champ in-the-making
Champ in-the-making
I had problem with my web service session timing out so I started to do a little bit of testing.

I realized that the web service session times out with the web-client session.
Let's say I set the session-timeout to 2 minutes in the web.xml, my web service session only lasts for 2 minutes.

I thought the web service ticket did not expire by default (ticketsExpire is set to false in authentication-service-context.xml)

I used the following code for testing and the get(Predicate) only executes twice before I get the WSSecurityEngine: Callback supplied no password … error:


AuthenticationUtils.startSession(USERNAME, PASSWORD);
System.out.println("Session started.");
       
    try
    {       
        for (int i = 0; i < 5; i++)
       {
            Reference reference = new Reference(STORE, null, xpath);
            Predicate predicate = new Predicate(
                new Reference[] {reference}, STORE, null);
            Node[] nodes =
                WebServiceFactory.getRepositoryService().get(predicate);
            Thread.sleep(1 * 60000);
       }
    }
    finally
    {
        // End the session
        AuthenticationUtils.endSession();
        System.out.println("Session ended.");
    }
}

Someone knows what is going on?

Thanks!
9 REPLIES 9

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

No I'm not entirly sure what's going on here.  I think I'm going to need to try this out and see what behaviour I get.

I'll get back to you when I've made some progress.

Cheers,
Roy

benjamin_doughe
Champ in-the-making
Champ in-the-making
I'm getting this issue too, I can't reproduce the time out via a java web service client but I am getting the error with a windows client.

Seems when the session time out occurs the password request callback fails.

Ben.

benjamin_doughe
Champ in-the-making
Champ in-the-making
Ok it looks like org.alfresco.web.app.ContextListener.sessionDestroyed invalidates the ticket - which is I suppose what you should expect. I presume this is occurring after a specified timeout which I guess is the web.xml session-timeout setting.

That all makes sense and is what you want to happen although I'm not sure why this didn't occur in previous Alfresco versions.

So.. my question is what would be the best method to handle this? Force the session to be kept alive or listen (somehow) for session death and then re-establish?

If there's a standard way to do this please forgive my ignorance.

ta,
Ben.

dwilson
Champ in-the-making
Champ in-the-making
…So.. my question is what would be the best method to handle this? Force the session to be kept alive or listen (somehow) for session death and then re-establish?

If there's a standard way to do this please forgive my ignorance.

Ben, did you find a solution for the best method in this situation?  I have the same query.

Thanks.

thierensbart
Champ in-the-making
Champ in-the-making
I'm having the same problem.

I have a Webservice based Java app that stays alive (or rather: should stay alive) for days.

Has anyone tested setting the session-timeout to 0 in web.xml?

thierensbart
Champ in-the-making
Champ in-the-making
As a reply to my own question:

I set the session-timeout of the Alfresco web-app to 0 in web.xml and it seems to do the trick.

My connection stays open for days with nonstop datatraffic from downloading files.

ashantycapre
Champ in-the-making
Champ in-the-making
pLEAsANT gREEtings!!!


I had problem with my web service session timing out so I started to do a little bit of testing.

I realized that the web service session times out with the web-client session.
Let's say I set the session-timeout to 2 minutes in the web.xml, my web service session only lasts for 2 minutes.

I thought the web service ticket did not expire by default (ticketsExpire is set to false in authentication-service-context.xml)

I used the following code for testing and the get(Predicate) only executes twice before I get the WSSecurityEngine: Callback supplied no password … error:

Code: Select all
    AuthenticationUtils.startSession(USERNAME, PASSWORD);
    System.out.println("Session started.");
          
        try
        {      
            for (int i = 0; i < 5; i++)
           {
                Reference reference = new Reference(STORE, null, xpath);
                Predicate predicate = new Predicate(
                    new Reference[] {reference}, STORE, null);
                Node[] nodes =
                    WebServiceFactory.getRepositoryService().get(predicate);
                Thread.sleep(1 * 60000);
           }
        }
        finally
        {
            // End the session
            AuthenticationUtils.endSession();
            System.out.println("Session ended.");
        }
    }


Anyone can contribute something or any ideas that could fix this matter?
Im looking forward for a very positive response!
tHank you!!

how to hypnotize people

nathanjosh32
Champ in-the-making
Champ in-the-making
As a reply to my own question:

I set the session-timeout of the Alfresco web-app to 0 in web.xml and it seems to do the trick.

My connection stays open for days with nonstop datatraffic from downloading files.


Hi ThierensBart  thanks for that help that's really good!

cristian
Champ in-the-making
Champ in-the-making
To set the session timeout try to start the session using:
AuthenticationUtils.startSession(username, password, timeoutInterval);
…where timeoutInterval is the age of your ticket in milliseconds.
Then you can check if your ticket is timed out or not with:
AuthenticationUtils.isCurrentTicketTimedOut()
It will return true if the ticket is expired.  In this case you might want to destroy the session created during a valid login operation.
If timeoutInterval is not set it will return false.