spring-projects / spring-session

Spring Session
https://spring.io/projects/spring-session
Apache License 2.0
1.86k stars 1.12k forks source link

Multiple sessions are created when the first request is made #1431

Open violetmoon027 opened 5 years ago

violetmoon027 commented 5 years ago

When service A calls service B when feign is used, service A is not saved to redis after the session is created, causing service B to obtain the session empty according to the request of service A, and mistakenly think that it is a new request and re-create the session.

rwinch commented 5 years ago

@violetmoon027 Thanks for the report! Do you have flush mode set to immediate?

violetmoon027 commented 5 years ago

spring: session: store-type: redis redis: flush-mode: immediate

I tried this setting, but the first visit will still create two sessions.

violetmoon027 commented 5 years ago

spring.session.store-type=redis spring.redis.flush-model=immediate feign.hystrix.enable=true

This is my current configuration

violetmoon027 commented 5 years ago

https://github.com/violetmoon027/SpringSession-Demo.git

This is a small scene that can reproduce this problem.

First prepare a redis, then empty redis, then just pull the project and run, then access service A's /index and observe the session changes.