Excessive session creation

21 views
Skip to first unread message

Peter Jacobs

unread,
Jun 24, 2022, 6:25:09 AMJun 24
to vert.x
I'm replacing an obsolete Jetty 9 + Shiro site with vertx 4.2.7.

All is well except every GET of a static resource is generating a new session.  Any ideas on how to avoid this please?  If necessary I can create a seperate server on a different port without a session handler, but I guess I'm simply missing something in the server config.

            Router router = Router.router(vertx);
            router.route()
                    .handler(SessionHandler.create(sessionStore))
                    .handler(FaviconHandler.create(vertx,
                            SitesManager2.getSitesPath().resolve("favicon.ico").toString()))
                    .handler(LoggerHandler.create(LoggerFormat.TINY))
                    .handler(bodyHandler).handler(basicAuthHandler)
                    .handler(this::maintenanceFilter)
                    .handler(this::clientAccessFilter2);
            // static routes (new session every time...)
            router.get("/static/*").handler(StaticHandler.create());
            // other routes (existing session honoured)
            ...

TIA

Nils Renaud

unread,
Jun 27, 2022, 3:29:50 AMJun 27
to vert.x
There is a solution for your issue: you can set the SessionHandler as Lazy.
SessionHandler.create(sessionStore).setLazySession(true)

Thomas SEGISMONT

unread,
Jun 28, 2022, 5:11:28 AMJun 28
to ve...@googlegroups.com
Thanks Nils for sharing the solution!


Would you mind contributing an update?

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/3bb63e72-b6af-4875-a7ea-b0b617a0e95bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages