HTTP

HTTP 101 Switching Protocols vs 503 Service Unavailable

HTTP 101 (Switching Protocols) is a 1xx Informational response, while 503 (Service Unavailable) is a 5xx Server Error response. 101 indicates that the server understands the Upgrade header field request and indicates which protocol it is switching to. In contrast, 503 means that the server is temporarily unable to handle the request due to maintenance or overload. Should include a Retry-After header.

คำอธิบาย

The server understands the Upgrade header field request and indicates which protocol it is switching to.

เมื่อคุณพบเห็น

When upgrading from HTTP/1.1 to WebSocket, or to HTTP/2.

วิธีแก้ไข

This is normal behavior during protocol upgrades. Ensure your client supports the target protocol.

คำอธิบาย

The server is temporarily unable to handle the request due to maintenance or overload. Should include a Retry-After header.

เมื่อคุณพบเห็น

During maintenance windows, server overload, or when the application pool is exhausted.

วิธีแก้ไข

Wait and retry. Check the Retry-After header. Scale up servers if it's a capacity issue.

ความแตกต่างหลัก

1.

101 is a 1xx Informational response, while 503 is a 5xx Server Error response.

2.

HTTP 101: The server understands the Upgrade header field request and indicates which protocol it is switching to.

3.

HTTP 503: The server is temporarily unable to handle the request due to maintenance or overload. Should include a Retry-After header.

4.

You encounter 101 when when upgrading from HTTP/1.1 to WebSocket, or to HTTP/2.

5.

You encounter 503 when during maintenance windows, server overload, or when the application pool is exhausted.

ควรใช้อันไหนเมื่อไร

For 101 (Switching Protocols): This is normal behavior during protocol upgrades. Ensure your client supports the target protocol. For 503 (Service Unavailable): Wait and retry. Check the Retry-After header. Scale up servers if it's a capacity issue.

เรียนรู้เพิ่มเติม