Right now we are storing the session in map. So very first time , when we create session, it is possible that the session got created ,but due to some issue ,it immediately disconnected and logged out.
After some time, being the sessionId present in map, we are calling just lookup for that session and call logOn() . It should call my overridden logon() method which is not happening. Can anyone tell me the the possible clause and how to handle this ?when I see the logs, it's showing EndOfStream occurred,disconnecting.
Related
When getting the callback to /Account/ExternalLoginCallback the call to SignInManager.GetExternalLoginInfoAsync returns info just fine. The user then registers and the callback to /Account/ExternalLoginConfirmation is called and SignInManagerGetExternalLoginInfoAsync now returns null. The data isn't staying around for some reason.
If I look at requests through Fiddler, I can see in the call to /Account/ExternalLoginCallback that there is a cookie named Identity.External. When calling /Account/ExternalLoginConfirmation, that cookie is no longer there. I think this is the problem, but I have no clue why. In between these two calls there is a call for the /favicon.ico file that returns a 302 causing a call to /Account/Login?ReturnUrl=%2Ffavicon.ico. Both those calls still have the Identity.External cookie showing.
This just started happening and I can't figure out why.
I am trying to login with two text boxes (username and password). I am sending those two variables to web service to check whether there is username and password is available or not. I get the response as message "success" or "failure" from web service with respect to those two values. Then i am fetching that message and with that message i am setting a flag value. But after the session i am not getting that flag value. its showing the default value false.
The problem is i want to login on button action which will call web service using URLSession and data task and i am not able to set the flag. I can do it with NSURL synchronous request but that code is deprecated.
You can view images for the code for login button action function as well as web service function.
login button action
web service function
Thank you in advance.
The way you are using the method webServiceCalledMethod is wrong. The task associated with the URLSession is executed asyncronously. As a result, isLogin variable is returned before your dataTask gets executed.
Instead of returning Bool from asyncronous method, use either closure or delegate pattern to notify of the data task completion state.
I've already searched via google and on stackoverflow, but could not find any similar problem to mine.
In my project I'm handling a ViewExpiredException properly and show a custom page to the user that the current session has timed out. This works great, but I want to do something BEFORE this message gets shown to the user. Actually I'm working with 2 different sessions here, one on the frontend side and one on the backend, so the idea is to NOT start a new backend session when the current one timed out.
Is there any possibility to fetch the ViewExpiredException while I'm inside the doFilter method, so I do not start a new backend session (simply because it is not needed)? Or is there any other way?
I already tried to fetch the current context via
FacesContext fc = FacesContext.getCurrentInstance();
But obviously the context is null, because the session timed out.
Inside the ExceptionHandlerWrapper I have access to the UnhandledExceptionQueuedEvents, but this does not help me here since I need this information earlier.
I hope I made my problem clear enough.
Thanks in advance for any help!
Regards
Sebastian
Generally ViewExpiredException is thrown when a POST request is fired while the session is timed out. So, this should do in the filter:
boolean post = "POST".equals(request.getMethod());
boolean timedout = request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid();
if (post && timedout) {
// JSF will guaranteed throw ViewExpiredException when state saving is set to server.
}
But this does not cover all possible cases. ViewExpiredException can also occur when the session hasn't timed out. For example, when the client has passed an invalid javax.faces.ViewState parameter, or when the associated view has been pruned from the LRU map which can by default hold 15 views. This is however not detectable inside a servlet filter before FilterChain#doFilter() is called. You really need to be inside the JSF context. You could do the backend session creating job in a PhaseListener. E.g. in beforephase of apply request values phase, which is guaranteed to be invoked only when there's a vaild view.
By the way, the FacesContext is not null in the filter because the session has timed out, but because the FacesServlet, the one responsible for creating it, hasn't been invoked yet at that point. You know, filters run before servlets.
When i try to capture video by using AVFramework i receive an exception -11803, which says that the session is not started, the first time when i init session it works fine, but after when controller changes and then again return to the same controller it throws an exception, but in same session image capture works fine.
problem solved,the issue was that the session object was not deallocated properly.
I am using valueUnbound method of HttpSessionBindingListener to release lock(an entry from the database), before session is about to expire:
#Override
public void valueUnbound(HttpSessionBindingEvent event) {
String user = (String) event.getSession().getAttribute("currentUsr");
removeLock(user);
}
When the lock is set, I am setting up the username as a session variable.
I need this "username" in my remove lock method. But the getAttribute is throwing an exception:
java.lang.IllegalStateException: getAttribute: Session already invalidated
I need help in getting the session variable?? or is there any other way to get the username?
No, since session has been invalidated.
Although, I figured out the solution, I am setting the attribute via servlet context in
valueBound method and getting it through the : event.getSession().getServletContext().getAttribute("cUser");
it works fine. Thank You EJP
I got your point EJP, you are right , I am making it complex, I can get it from event.getValue() . +1 to your answer, Thank You.
Although, I figured out the solution, I am setting the attribute via servlet context in valueBound method and getting it through the : event.getSession().getServletContext().getAttribute("cUser");
So.. You are storing session scoped data in the application scope. Do you realize that this way the data is shared among all visitors of the webapp? Visitor X would then see the attribute set by visitor Y which has visited the website at a later moment. It makes the problem only worse.
Anyway, as to the concrete problem, as the exception message is trying to tell you, the session has already been invalidated at that point. There are two ways to solve this:
Make currentUsr a property of the class which is implementing HttpSessionBindingListener, so that you don't need to grab it as a distinct session attribute.
Use a HttpSessionListener instead. The sessionDestroyed() method is called right before invalidation, so you should still have access to all attributes.