httpbin - 协议调试工具
httpstatuses - 协议状态码查询
httpie - cURL-like tool for humans
Fiddler
vevlins
V2EX  ›  HTTP

短时间发送大量请求 http 返回 421

  •  
  •   vevlins · Oct 15, 2019 · 4696 views
    This topic created in 2424 days ago, the information mentioned may be changed or developed.

    421 的原因到底是什么?谷歌的结果看不明白“This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.”

    421 怎么解决呢?

    3 replies    2019-10-16 16:13:50 +08:00
    vevlins
        1
    vevlins  
    OP
       Oct 15, 2019
    在 RFC 中找到了一个合理的答案," A server that does not wish clients to reuse connections can indicate
    that it is not authoritative for a request by sending a 421
    (Misdirected Request) status code in response to the request (see
    Section 9.1.2).",golang 中复用了 http 长链接,我这里请求的客户端似乎会检测一个长连接上的请求次数,如果超过一定量就会返回 421.
    lingbopc
        2
    lingbopc  
       Oct 16, 2019   ❤️ 1
    server 端是 nginx 么?有一个指令会指定一个长连接最多可以处理端请求数量,你可以参考一下

    keepalive_requests 指令用于设置一个 keep-alive 连接上可以服务的请求的最大数量,当最大请求数量达到时,连接被关闭。默认是 100
    当一个 keep alive 建立之后,nginx 就会为这个连接设置一个计数器,记录这个 keep alive 的长连接上已经接收并处理的客户端请求的数量。如果达到这个参数设置的最大值时,nginx 会强制关闭这个长连接,使得客户端必须重新建立长连接
    当 qps 较大时,建议增加这个值,否则会导致大量的 TIME_WAIT 的 socket 连接
    vevlins
        3
    vevlins  
    OP
       Oct 16, 2019
    @lingbopc 是的,找到了。但是我有一个疑问是在一个 keep-alive 上当达到一定数量后就会返回 421,但是几次之后又正常了。我使用的是 golang,这里失败几次后又正常是 nginx 又接受了还是 golang http 底层新开了一个长连接呢?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5491 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 01:33 · PVG 09:33 · LAX 18:33 · JFK 21:33
    ♥ Do have faith in what you're doing.