Hardcoded 5 second timeout for writing pong response can cause errors
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- go
- Lĩnh vực
- networking
Hướng nghiên cứu
Bắt đầu với luồng ping đến trong read.go, xung quanh trình xử lý opPing, và đường dẫn ghi pong trong write.go, xung quanh các context năm giây được hardcode. Tái hiện hoặc phân tích một mutex ghi bị chặn và một kết nối bị gián đoạn, sau đó quyết định timeout ping/pong nên hoạt động như thế nào. Hoàn thành khi kết nối không còn bị lỗi sớm trong các điều kiện được báo cáo và giá trị mặc định hoặc cấu hình được chọn được kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
An inbound ping has a hardcoded 5 second deadline to handle the incoming message and send out a pong response. The general codepath for such a scenario is:
Conn.readLoop->h.opcode==opPing->handleControl(..., opPing)->writeControl(..., opPong)
The two 5 second context-based timeouts declared here:
- https://github.com/coder/websocket/blob/9f473adfa59519d1e0295cd7a988d965085b701a/read.go#L302
- https://github.com/coder/websocket/blob/9f473adfa59519d1e0295cd7a988d965085b701a/write.go#L277
These timeouts can cause the Websocket connection to close with an unrecoverable error. I can go into more detail about the two possible situations that can cause this condition if required, but just note that the network connection is extremely poor both in reliability and speed, and the connection is generally busy sending data (chunked enough to allow the incoming ping frames to be handled for the average network speed assuming no interruptions).
failed to get reader: failed to handle control frame opPing: failed to write control frame opPong: failed to acquire lock: context deadline exceeded
The problem mostly arises when the connection is briefly interrupted or the write mutex is otherwise busy underneath an in-flight inbound ping message. This 5 second timeout is not enough to be able to write the pong response.
Proposals:
- Allow this timeout value to be configurable - at the very least for ping/pong control frames.
- Increase this hardcoded timeout to 20 seconds by default - perhaps only for ping/pong frames?
This is generally more in line with other implementations I've found that have a default value - though most do not have a default timeout at all and rely on the user to implement ping handling in their own way.
- https://websockets.readthedocs.io/en/stable/reference/asyncio/client.html#websockets.asyncio.client.connect -
open_timeout=10, ping_interval=20, ping_timeout=20, close_timeout=10 - https://socket.io/docs/v4/server-options/#pingtimeout (granted this isn't a pure Websocket library)
Definitely open to other ideas, and I'm happy to get a PR up for this, but for now I've forked the repo to change this value.
- Ngôn ngữ chính
- Go
- Star
- 5.5k
- Fork
- 379
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của coder/websocket
-
Must not wrap io.EOFĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
export wstestĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
Tất cả issue của coder/websocket
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Docker AgentĐang mởnew-entry
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
prime-radiant-inc/alltheagents.org#43 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày