강의

멘토링

커뮤니티

Inflearn Community Q&A

jsj32820415's profile image
jsj32820415

asked

System design where you can't get promoted if you don't know

System Design for Over a Million Users, Considered from Service Launch

websocket 연결 질문

Resolved

Written on

·

37

0

일반적으로 websocket 연결은 클라이언트 쪽에서 먼저 하나요? 혹은 서버쪽에서 먼저 하게 되나요?

또한 연결을 끊을때도 클라이언트/서버 어느쪽에서 먼저 하게 되는지 궁금합니다!

백그라운드 상태에서도 websocket 연결은 계속 유지되고 있나요?

소프트웨어-설계시스템-디자인

Answer 1

2

freeaion님의 프로필 이미지
freeaion
Instructor

서버는 port를 열어두고 listening상태에서 대기하고 있고, client가 http request를 보내 initial handshake를 시작하게 됩니다. initial handshake를 보낼 때 http header에 connection을 websocket으로 upgrade하고 싶다고 요청하게 됩니다. server가 handshake을 accept하면 websocket이 연결되게 됩니다.

 

연결을 끊는 것은 closing handshake에 의해 이루어지고, closing은 server나 client 어느쪽도 먼저 시작할 수 있습니다.

 

백그라운드 상태에서도 "persistent"한 연결이 유지됩니다. websocket이 연결되면, full-duplex, persistent TCP connection이라고 생각하시면 됩니다.

jsj32820415's profile image
jsj32820415

asked

Ask a question