v2ray / discussion

For general discussion over Project V development and usage.
299 stars 34 forks source link

关于v2ray h2+tls 间接性连接中断的问题 #705

Closed Jason-2048 closed 4 years ago

Jason-2048 commented 4 years ago

如题,h2+tls间接性中断,ws+tls未发现此问题 服务端配置:

{
  "log": {
    "loglevel": "debug",
    "access": "/etc/v2ray/access.log",
    "error": "/etc/v2ray/error.log"
  },
  "inbounds": [
    {
      "port": "*",
      "listen": "127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "*",
            "alterId": 128
          }
        ]
      },
      "streamSettings": {
        "network": "h2",
        "security": "tls",
        "httpSettings": {
          "path": "/apple",
          "host": [
            "*"
          ]
        },
        "tlsSettings": {
          "serverName": "*",
          "certificates": [
            {
              "certificateFile": "*",
              "keyFile": "*"
            }
          ]
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

客户端使用v2ray官方的v2ray.exe 配置如下:

{
  "log": {
    "loglevel": "warning",
    "access": "*",
    "error": "*"
  },
  "inbounds": [
    {
      "port": 10888,
      "listen": "127.0.0.1",
      "protocol": "http",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth",
        "udp": true
      }
    },
    {
      "port": 10889,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth",
        "udp": true
      }
    },
    {
      "tag":"transparent",
      "port": 10890,
      "protocol": "dokodemo-door",
      "settings": {
        "network": "tcp,udp",
        "followRedirect": true
      },
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "streamSettings": {
        "sockopt": {
          "tproxy": "tproxy"
        }
      }
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "*",
            "port": 443,
            "users": [
              {
                "id": "*",
                "alterId": 128
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "h2",
        "security": "tls",
        "tlsSettings": {
          "allowInsecure": false,
          "serverName": "*"
        },
        "httpSettings": {
          "path": "/apple",
          "host": [
            "*"
          ]
        },
        "mux": {
          "enabled": false
        }
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "UseIP"
      },
      "streamSettings": {
        "sockopt": {
          "mark": 255
        }
      }
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    },
    {
      "tag": "dns-out",
      "protocol": "dns",
      "streamSettings": {
        "sockopt": {
          "mark": 255
        }
      }  
    }
  ],
  "dns": {
    "host": {
      "*": "*"
      },
    "servers": [
      "8.8.8.8",
      "8.8.4.4",
      "1.0.0.1",
      "208.67.222.222",
      "208.67.220.220",
      "208.67.222.220",
      "208.67.220.222",
      "114.114.114.114",
      {
        "address": "223.5.5.5",
        "port": 53,
        "domains": [
         "geosite:cn",
         "ntp.org"
       ]
      }
    ],
    "clientIp": "*"
  },
  "routing": {
    "domainStrategy": "IPOnDemand",
    "rules": [
      {
        "type": "field",
        "inboundTag": [
          "transparent"
        ],
        "port": 53,
        "network": "tcp,udp",
        "outboundTag": "dns-out"
      },
      {
        "type": "field",
        "inboundTag": [
          "transparent"
        ],
        "port": 123,
        "network": "udp",
        "outboundTag": "direct" 
      },
      {
        "type": "field", 
        "ip": [
          "223.5.5.5",
          "114.114.114.114"
        ],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": [
          "8.8.8.8",
          "8.8.4.4",
          "1.0.0.1",
          "208.67.222.222",
          "208.67.220.220",
          "208.67.222.220",
          "208.67.220.222"
        ],
        "outboundTag": "proxy"
      },
      {
        "type": "field",
        "outboundTag": "block",
        "domain": ["geoip:category-ads"]
      },
      {
        "type": "field",
        "protocol":["bittorrent"], 
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "ip": [
          "geoip:cn",
          "geoip:private"
          ]
      },
      {
        "type": "field", 
        "domain": [
          "geosite:cn"
        ],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "network":"tcp,udp",
        "outboundTag": "proxy"
      }
    ]
  }
}

caddyfile:

http://aa.aa {
    redir https://aa.aa{url}
}

https://aa.aa {
    log stdout
    errors stderr
    gzip
    root /var/www
    tls aa@qq.com
    fastcgi / 127.0.0.1:9000 php {
    env PATH / bin
    ext .php
    split .php
    index index.php
    }
    proxy /apple https://127.0.0.1:* {
        insecure_skip_verify
        header_upstream Host {host}
        header_upstream X-Real-IP {remote}
        header_upstream X-Forwarded-For {remote}
        header_upstream X-Forwarded-Port {server_port}
        header_upstream X-Forwarded-Proto "https"
    }
}

caddy报错如下:

May 31 20:02:42 izj6c9w2i06ratgd5eec82z caddy[14629]: 2020/05/31 20:02:42 [ERROR] failed to copy buffer:  context canceled
May 31 20:02:42 izj6c9w2i06ratgd5eec82z caddy[14629]: 2020/05/31 20:02:42 xx.xx.xx.xx - - [31/May/2020:20:02:42 +0800] "PUT /apple HTTP/2.0" 200 0

服务端日志如下: access.log:

2020/05/31 20:02:36 127.0.0.1:60492 accepted udp:8.8.8.8:53 
2020/05/31 20:02:36 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 5; CANCEL
2020/05/31 20:02:36 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 1; CANCEL
2020/05/31 20:02:37 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 13; CANCEL
2020/05/31 20:02:37 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 11; CANCEL
2020/05/31 20:02:37 127.0.0.1:60492 accepted tcp:www.google.com:80 
2020/05/31 20:02:37 127.0.0.1:60492 accepted tcp:www.google.com:443 
2020/05/31 20:02:37 127.0.0.1:60492 accepted tcp:cfg.flurry.com:443 
2020/05/31 20:02:39 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 17; CANCEL
2020/05/31 20:02:39 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 19; CANCEL
2020/05/31 20:02:39 127.0.0.1:60492 accepted tcp:data.flurry.com:443 
2020/05/31 20:02:40 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 23; CANCEL
2020/05/31 20:02:40 127.0.0.1:60492 accepted tcp:www.google.com:443 
2020/05/31 20:02:40 127.0.0.1:60492 accepted udp:www.google.com:443 
2020/05/31 20:02:41 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 29; CANCEL
2020/05/31 20:02:41 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 31; CANCEL
2020/05/31 20:02:42 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 33; CANCEL
2020/05/31 20:02:42 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 35; CANCEL
2020/05/31 20:02:42 127.0.0.1:60492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 37; CANCEL

error.log:

2020/05/31 20:02:25 [Debug] v2ray.com/core/app/log: Logger started
2020/05/31 20:02:25 [Debug] v2ray.com/core/app/proxyman/inbound: creating stream worker on 127.0.0.1:35353
2020/05/31 20:02:25 [Warning] v2ray.com/core: V2Ray 4.23.1 started
2020/05/31 20:02:36 [Info] [1967198181] v2ray.com/core/proxy/vmess/inbound: received request for udp:8.8.8.8:53
2020/05/31 20:02:36 [Info] [1967198181] v2ray.com/core/app/dispatcher: default route for udp:8.8.8.8:53
2020/05/31 20:02:36 [Info] [1967198181] v2ray.com/core/proxy/freedom: opening connection to udp:8.8.8.8:53
2020/05/31 20:02:36 [Info] [3061461870] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 5; CANCEL
2020/05/31 20:02:36 [Info] [4046358939] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 1; CANCEL
2020/05/31 20:02:37 [Info] [434374649] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 13; CANCEL
2020/05/31 20:02:37 [Info] [155584763] v2ray.com/core/proxy/vmess/inbound: received request for tcp:www.google.com:80
2020/05/31 20:02:37 [Info] [1975859346] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 11; CANCEL
2020/05/31 20:02:37 [Info] [1006516973] v2ray.com/core/proxy/vmess/inbound: received request for tcp:www.google.com:443
2020/05/31 20:02:37 [Info] [155584763] v2ray.com/core/app/dispatcher: default route for tcp:www.google.com:80
2020/05/31 20:02:37 [Info] [155584763] v2ray.com/core/proxy/freedom: opening connection to tcp:www.google.com:80
2020/05/31 20:02:37 [Info] [155584763] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:www.google.com:80
2020/05/31 20:02:37 [Info] [1006516973] v2ray.com/core/app/dispatcher: default route for tcp:www.google.com:443
2020/05/31 20:02:37 [Info] [1006516973] v2ray.com/core/proxy/freedom: opening connection to tcp:www.google.com:443
2020/05/31 20:02:37 [Info] [1006516973] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:www.google.com:443
2020/05/31 20:02:37 [Info] [4048474822] v2ray.com/core/proxy/vmess/inbound: received request for tcp:cfg.flurry.com:443
2020/05/31 20:02:37 [Info] [4048474822] v2ray.com/core/app/dispatcher: default route for tcp:cfg.flurry.com:443
2020/05/31 20:02:37 [Info] [4048474822] v2ray.com/core/proxy/freedom: opening connection to tcp:cfg.flurry.com:443
2020/05/31 20:02:37 [Info] [4048474822] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:cfg.flurry.com:443
2020/05/31 20:02:39 [Info] [4008056193] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 17; CANCEL
2020/05/31 20:02:39 [Info] [3908401629] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 19; CANCEL
2020/05/31 20:02:39 [Info] [1854804676] v2ray.com/core/proxy/vmess/inbound: received request for tcp:data.flurry.com:443
2020/05/31 20:02:39 [Info] [1854804676] v2ray.com/core/app/dispatcher: default route for tcp:data.flurry.com:443
2020/05/31 20:02:39 [Info] [1854804676] v2ray.com/core/proxy/freedom: opening connection to tcp:data.flurry.com:443
2020/05/31 20:02:39 [Info] [1854804676] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:data.flurry.com:443
2020/05/31 20:02:40 [Info] [880213199] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 23; CANCEL
2020/05/31 20:02:40 [Info] [2813872823] v2ray.com/core/proxy/vmess/inbound: received request for tcp:www.google.com:443
2020/05/31 20:02:40 [Info] [2813872823] v2ray.com/core/app/dispatcher: default route for tcp:www.google.com:443
2020/05/31 20:02:40 [Info] [2813872823] v2ray.com/core/proxy/freedom: opening connection to tcp:www.google.com:443
2020/05/31 20:02:40 [Info] [2813872823] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:www.google.com:443
2020/05/31 20:02:40 [Info] [968874257] v2ray.com/core/proxy/vmess/inbound: received request for udp:www.google.com:443
2020/05/31 20:02:40 [Info] [968874257] v2ray.com/core/app/dispatcher: default route for udp:www.google.com:443
2020/05/31 20:02:40 [Info] [968874257] v2ray.com/core/proxy/freedom: opening connection to udp:www.google.com:443
2020/05/31 20:02:41 [Info] [2182600350] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 29; CANCEL
2020/05/31 20:02:41 [Info] [3848293641] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 31; CANCEL
2020/05/31 20:02:42 [Info] [155584763] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: failed to transfer request > stream error: stream ID 7; CANCEL
2020/05/31 20:02:42 [Info] [968874257] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: failed to transfer request > stream error: stream ID 27; CANCEL
2020/05/31 20:02:42 [Info] [3464250072] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 33; CANCEL
2020/05/31 20:02:42 [Info] [2364562856] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 35; CANCEL
2020/05/31 20:02:42 [Info] [3420840208] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 127.0.0.1:60492 > v2ray.com/core/proxy/vmess/encoding: failed to read request header > stream error: stream ID 37; CANCEL
2020/05/31 20:02:42 [Info] [1967198181] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: failed to transfer request > stream error: stream ID 3; CANCEL
2020/05/31 20:02:42 [Info] [1006516973] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: failed to transfer request > stream error: stream ID 9; CANCEL
2020/05/31 20:02:42 [Info] [155584763] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/05/31 20:02:42 [Info] [968874257] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/05/31 20:02:42 [Info] [1967198181] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/05/31 20:02:42 [Info] [1006516973] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/05/31 20:02:42 [Info] [1854804676] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/05/31 20:02:42 [Info] [1854804676] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > io: read/write on closed pipe
2020/05/31 20:02:42 [Info] [2813872823] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/05/31 20:02:42 [Info] [2813872823] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > io: read/write on closed pipe
2020/05/31 20:02:42 [Info] [4048474822] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/05/31 20:02:42 [Info] [4048474822] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > io: read/write on closed pipe

拿日志的时候时间错开了点

xianren78 commented 4 years ago

对,h2有这个问题,从一开始就有。

Jason-2048 commented 4 years ago

对,h2有这个问题,从一开始就有。

是h2自己的问题,还是v2ray的问题呢。。

AmberisMyShiba commented 4 years ago

我升级到4.23.2后也遇到了这个问题。

Jason-2048 commented 4 years ago

我升级到4.23.2后也遇到了这个问题。

我是4.23.1版本,并且有人表示这可能是h2的tcp头阻塞

AmberisMyShiba commented 4 years ago

看日志应该是caddy的问题。

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days