vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
617 stars 167 forks source link

Hazelcast session causes page recursive reload #17799

Open bardyamomeni opened 1 year ago

bardyamomeni commented 1 year ago

Description of the bug

Whenever instead of normal HTTP sessions I try to use distributed sessions using Hazelcast, trying to load the Vaadin app causes recursive refresh.

Removing the hazelcast session and switching to local session solves the problem.

Expected behavior

The app should be shown instead of getting trapped in refresh loop

Minimal reproducible example

just add

<dependency>
   <groupId>org.springframework.session</groupId>
   <artifactId>spring-session-hazelcast</artifactId>
</dependency>

with hazelcast bean

@Bean
    fun hazelcastInstance(): HazelcastInstance {
        val config = Config()
        config.addMapConfig(MapConfig(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME)
                .also { sessionMapConfig ->
                    sessionMapConfig
                        .addAttributeConfig(
                            AttributeConfig()
                                .setName(HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)
                                .setExtractorClassName(PrincipalNameExtractor::class.java.getName())
                        ).addIndexConfig(
                            IndexConfig(
                                IndexType.HASH,
                                HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE
                            )
                        )

                })
        return Hazelcast.newHazelcastInstance(config)
    }

Versions

mcollovati commented 1 year ago

This is somehow expected because of how Spring Session deserialize and serialize the session at every request.

Take a look at the following issues

bardyamomeni commented 1 year ago

@mcollovati Thanks for the information

That is very odd behaviour from the Vaadin team, they provide something that does not work (distributed session), and expect the user to pay for the fix by having the Kubernetes kit? That is not a sustainable approach IMHO!

I think having the foundation of HA available to users free of charge is a must!

I hope this problem gets attention!

knoobie commented 1 year ago

You can archive high availability by using Sticky Sessions and a properly configured proxy server which allows draining of sessions pretty easily.

tarekoraby commented 1 year ago

What @knoobie said, there is also a blog post describing how to use Hazelcast with Vaadin: https://vaadin.com/blog/vaadin-and-hazelcast-a-match-made-in-heaven.

shubham-m commented 12 months ago

Same behaviour is also observed when you add JDBC based Sessions