Adobe CQ5 - How to handle Session Timeout - aem

I want to know something about the Session Timeout on the Day CQSE HTTP Service. Is it possible to handle the exception that is thrown knowing that it is actually a Session Timeout Exception? I mean, on the controller part of the system (I use Java Spring), the exception I got is a NullPointerException after the timeout minutes has passed, and at this point the session is already reseted, making not possible to inform the user that his session has timed out, but only that "An error ocurred".
Thanks a lot,

Related

what can cause this exception? io.vertx.core.impl.NoStackTraceThrowable: Connection is not active now, current status: CLOSED

i had built a http server by vertx-web, and it has working well for several days.
but today, when i make some http request, there sometimes throw this exception: "io.vertx.core.impl.NoStackTraceThrowable: Connection is not active now, current status: CLOSED".
what make me confused is that not every http request will throw this exception, and for the same http uri, if i change the request params, this exception may happen, but not every time.
i wanne know why and thanks for you answer.

'PrematureCloseException: Connection premium closed DURING response' occurs when using WebClient

In normal cases, WebClient works well, but an exception occurs on particular api call.
The error log is as follows.
reactor.core.Exceptions$ReactiveException: reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response
Why is this happening?
Is there an API that is not supported WebClient calls?

Service response is a 502 Bad Gateway error with generic "Server Error" HTML block?

I wrote a Node service that takes parameters from a client and puts them into a SOAP request to another (3rd party) service. Lately, when a request is made to my service, the initial response is a 502 Bad Gateway error with a generic HTML block titled "Server Error" (see image). When I submit the same request a second time, the 3rd party responds with a 500 Internal Server error and a message indicating that a request has already been issued for that transaction.
Obviously the initial request made it to the 3rd party somehow, but they say that the 502 error isn't theirs and isn't logged in their system as ever having occurred.
What I'm trying to find out is if the error is somehow coming from my service because of Docker or Azure (or something else I'm not thinking of). The error is so generic that research hasn't yielded anything useful on it. Has anyone encountered this or know what it is?
It turns out that this was an error being thrown by Azure (or so we think) as the result of some faulty error-handling. Part of the response was being parsed incorrectly, which caused the app to stall. It still doesn't explain how the data still got to the other side while this was happening (or why it hit the catch block at all when there was no error in the processing), but if you see a server error returned with this HTML block, check your error-handling code and investigate Azure!

Failed to perform attach connection with Strophe.js

I'm using the attach feature from Strophe.js, so when I lose my internet connection I can keep the same session alive.
Sometimes it works properly and I can do the attach, while I don't have any problem making different requests.
The problem apparently occurs when a request is pending, in queue, and is sent after the attach reconnection.
For example, I perform the attach with rid = 100 and when I perform a request (example: retrieve the roster) , the rid request is now 101, but when I check the console, I can see an stanza with rid = 98 has been sent, so I got an item-not-found error and the session closes. I know this error is because the rid is not correct.
Any idea where I can modify the code to avoid sending malformed rid stanzas? or any possible solution?
Thanks

Handling HTTP session timeout and redirect in Eclipse RAP application

I am working on an Eclipse RAP application (RCP as web application). After the servlet container has invalidated the HttpSession (session timeout, setMaxInactiveInterval exceeded) the following exception is thrown when clicking on the application in the browser:
java.lang.NullPointerException
at org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.service(LifeCycleServiceHandler.java:66)
at org.eclipse.rap.rwt.engine.RWTServlet.handleValidRequest(RWTServlet.java:135)
...
So I implemented a javax.servlet.Filter that detects the situation and should now redirect somewhere to display a "session timeout, please reload" message.
My preferred solution for the "session timeout" warning would be a simple HTML5 page with a link back to the application. But I don't know how to integrate HTML5 pages with a RAP application (and whether that is a good idea to start with). Also I am not clear how and where the redirect should happen.
For redirecting I tried two variations in the Filter.
The first one gives me "Error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data":
httpServletResponse.sendRedirect("/myapp");
And this one "java.lang.IllegalStateException: Invalid thread access
at org.eclipse.rap.rwt.RWT.checkContext(RWT.java:704)"
UrlLauncher launcher = RWT.getClient().getService(UrlLauncher.class);
launcher.openURL("http://www.eclipse.org/");
So I am probably really going down the wrong path here...
Does anybody know of a standard way to deal with HTTP session timeout situations in an Eclipse RAP application?
Is the HTTP session the correct place to deal with this or should I be looking at org.eclipse.rap.rwt.service.UISession, or something else?
How can I redirect to the home of the application if it lives on an URL like "http://127.0.0.1:50045/myapp"?
Can I easily integrate simple HTML5 pages with a RAP application (pages in same Eclipse project, deployed in same WAR, available on same host)? Or will this be a tedious task that does not come out of the box?
First off, a NullPointerException should never happen during normal operations, please file a bug including the RAP version and a stacktrace.
Just a guess, the problem may be caused by invalidating the session from within the request processing. If this is the case, it may help to use the HttpSession method setMaxInactiveInterval with a small timeout instead.
The problem with redirects is that a RAP application sends background (a.k.a. Ajax) requests to the server and expects JSON responses in return. If your filter redirects to some other page, the RAP client receives an HTML page instead of JSON. In order to redirect the browser to another page, you should send a JSON response to the client that includes this redirect (see bug 388249):
{"head": {"redirect": "http://www.myurl.com/"}}
To integrate other HTML5 pages in your RAP application, consider the Browser widget.
System.exit(0) if you want termination to be fluid - then modify your application specific shutdown hooks/exit code response to notify as you please.
Java based RAP/RCP:
try{
HttpSessionCollector.terminationQueue.remove(RWT.getUISession().getId());
RWT.getUISession().getHttpSession().invalidate();
System.exit(0);
}catch(Exception ex){
ex.printStackTrace();
System.out.println("failed to terminate session. adding user back to sessions list");
HttpSessionCollector.add();
}