Skip to content

Conversation

@LimKangHyun
Copy link
Collaborator

@LimKangHyun LimKangHyun commented Jul 20, 2025

🛰️ Issue Number

Closes #84

🪐 작업 내용

핸드쉐이크 시, 인증객체 넘겨주는 방식을 변경

  • 원래 HttpSessionHandshakeInterceptor를 사용해 넘겨주도록 했었는데, CustomHandshakeInterceptor를 추가하면 @AfterHandshake를 오버라이드하여 핸드쉐이크시에, 로그나 메트릭 수집이 용이할 것 같아서 교체를 했습니다.
  • 또한, @BeforeHandshake를 사용하여 세션저장소가 아닌 http요청스레드에 존재하는 contextHolder의 유저정보를 웹소켓세션 스레드로 넘겨주도록 했습니다.
  • 세션저장소를 활용하여 웹소켓세션에 인증정보를 넘겨주는 방식이 표준이지만, 세션저장소에 많은 요청이 몰릴경우, 같은 세션저장소를 사용하기 때문에, 부하가 생길수 있다고 합니다. 반면에, ContextHolder를 사용하면 요청 컨텍스트에서 바로 꺼내서 넘겨줄 수 있으므로 서버 확장시 문제도 없고, 세션저장소의 단점을 보완할 수 있다고 합니다.

로그 및 메트릭 수집

  • 실제 서비스시 로그 및 메트릭 수집을 위해 @AfterHandshake아래에 TODO를 추가해놓았습니다. 해당 부분에서는 STOMP와 같은 논리적 연결이 아닌 실제 물리적 연결을 추적하고 수집할 수 있습니다.(사용자의 IP, userAgent 등)
  • 어떤 메트릭을 수집하면 서비스 운용에 도움이 될지 찾아보겠습니다!

STOMP 커맨드 로그에, 사용자 정보 추가

  • STOMP 커맨드 로그에 사용자 정보를 추가해 조금더 로그가 직관적이도록 변경했습니다.
스크린샷 2025-07-20 오후 6 29 12

📚 Reference

✅ Check List

  • 코드가 정상적으로 컴파일되나요?
  • 테스트 코드를 통과했나요?
  • merge할 브랜치의 위치를 확인했나요?
  • Label을 지정했나요?

@LimKangHyun LimKangHyun self-assigned this Jul 20, 2025
@LimKangHyun LimKangHyun added the enhancement New feature or request label Jul 20, 2025
@LimKangHyun LimKangHyun linked an issue Jul 20, 2025 that may be closed by this pull request
2 tasks
@LimKangHyun LimKangHyun changed the title Feat/84 [feat] 커스텀 HandshakeInterceptor 추가 Jul 20, 2025
Copy link
Collaborator

@sehee123 sehee123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인터셉터에 로그 추가 참 보기 좋네요 ...
서버 로그 확인할 때 더 파악하기 쉬울 것 같습니다.
감사합니다 ! 🥳

Copy link
Collaborator

@jiwon1217 jiwon1217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

세션 저장소에 대한 의존성이 줄어들어 좋은 것 같습니다 ! 고생하셨습니다

@LimKangHyun LimKangHyun removed the request for review from gomsbft July 21, 2025 02:25
@LimKangHyun LimKangHyun merged commit 2d0b0c0 into dev Jul 21, 2025
3 checks passed
@silver-eunjoo
Copy link
Collaborator

이렇게 깊게 생각하신다니 대단하십니다 !

잘 설명해주셔서 감사합니다 ! 이해했습니다 ! 감사합니다 :)

@LimKangHyun LimKangHyun deleted the feat/84 branch July 28, 2025 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 커스텀 HandshakeInterceptor 추가

6 participants