-
Notifications
You must be signed in to change notification settings - Fork 2
웹소켓 Unit Test & 네트워크 백오프 작업 #683
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
Conversation
leekangho0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다
| /// sendPing(:) 으로부터 받은 에러를 핸들링하는 메소드입니다. | ||
| /// - Parameter error: 에러를 전달받습니다. | ||
| /// - Returns: 재연결해야 한다면 true를 반환합니다. | ||
| private func handlePingError(_ error: Error) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
핑에서 발생하는 에러에 대해 알아봐야겠네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
핑에서 발생하는 에러가 엄청 많아서 재연결할만한 에러를 구분하는게 쉽지 않아보이더라구요🥲
#️⃣ 연관된 이슈
📝 작업 내용
웹소켓 Unit Test
테스트를 하기 위해서 주입받을 수 있는 테스트 가능한 구조로 변경했습니다. (Mock 객체 주입)
실제 네트워크 통신을 하지 않고 테스트 하기 위해서
MockURLSession과MockWebSocketTask를 만들어서 사용했습니다.네트워크 백오프
단순히 2초마다 재연결을 시도하는 방식에서 백오프 방식으로 변경했습니다.
실제로 네트워크 호출 횟수가 1분 기준으로 약 80% 감소했습니다.
Ping & Pong 재연결 로직 변경
Ping & Pong에서 수신되는 에러가 반드시 재연결이 필요한 네트워크 오류는 아니라는 사실을 확인했습니다.
재연결 해야하는 치명적인 에러인 경우에 한하여 재연결 하도록 로직을 변경했습니다.
scenePhase 웹소켓 릭 이슈
💬 리뷰 요구사항(선택)