Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/#315 unsubscribe, subscribe에 queue 적용 #337

Merged
merged 19 commits into from
Dec 3, 2024
Merged

Conversation

swkim12345
Copy link
Collaborator

close #336

✅ 작업 내용

  • unsubscribe 에러 수정
  • 모듈 초기화시 발생되는 socket 초기화 문제 queue로 해결

😎 체크 사항

  • label 설정 확인
  • 브랜치 방향 확인

@swkim12345 swkim12345 linked an issue Dec 3, 2024 that may be closed by this pull request
1 task
Copy link
Collaborator

@xjfcnfw3 xjfcnfw3 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다 👍 👍


await this.mutex.runExclusive(async () => {
const connectedSockets = await this.server.to(stockId).fetchSockets();
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

try-catch로 묶으신 이유가 궁금합니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

현재 try-catch로 에러처리하는 부분이 따로 없고, 외부 유저와 connection하는 부분이다 보니 예기치 못한 에러가 발생할 수 있다고 생각했습니다

@@ -7,24 +6,23 @@ import { RawData, WebSocket } from 'ws';
export class WebsocketClient {
static url = process.env.WS_URL ?? 'ws://ops.koreainvestment.com:21000';
private client: WebSocket;
//현재 factory 패턴을 이용해 할당하면 socket이 열리기 전에 message가 가는 문제가 있음.
// 소켓이 할당되기 전에(client에 소켓이 없을 때) message를 보내려 시도함.
private messageQueue: string[] = [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

shift하면 비용이 n이라 비효율적이라 큐를 쓰는게 좋긴하지만, JS에서는 직접 구현해야되는게 아쉽네요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이건 너무 아쉽습니다. 큐 말고 더 좋은 방법이 있을까 해서 onModuleInit도 고려했는 데, websocket을 열 수 있는 개수를 런타임때야 알 수 있으니 어쩔 수 없었다고 생각합니다.

Copy link
Collaborator

@baegyeong baegyeong left a comment

Choose a reason for hiding this comment

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

LGTM ~~

@swkim12345 swkim12345 merged commit 5344b26 into dev-be Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - subscribe, unsubscribe 시 오류 발생하는 문제
3 participants