v2ray / v2ray-core

A platform for building proxies to bypass network restrictions.
https://www.v2ray.com/
MIT License
45.37k stars 8.94k forks source link

打开某些网站时会卡30秒 #293

Closed aRe00t closed 6 years ago

aRe00t commented 7 years ago

版本: V2Ray v2.6.1 (One for all) 20161113 服务器: Ubuntu 16.10 x64 客户端: macOS 10.12.1 (16B2555) 试了几种访问方式: Chrome + SwitchyOmega + shadowsocks + 隐私模式 Chrome + SwitchyOmega + vmess + 隐私模式 Safari + shadowsocks 现象:

  1. 有些网站会卡上一段时间, 然后就打开了
  2. 访问 www.bjjs.gov.cn 时特别明显, 能稳定重现, 每次都是30秒. 直连该网站没有问题.

时间线: 15:17:50, 访问 www.bjjs.gov.cn, 页面一直是空白 15:18:20, 此时页面加载了一部分 15:18:50, 页面加载完毕

日志

2016/11/17 15:17:50 [Info]Socks: TCP Connect request to tcp:www.bjjs.gov.cn:80
2016/11/17 15:17:50 [Info]DefaultDispatcher: Taking detour [direct] for [tcp:www.bjjs.gov.cn:80].
2016/11/17 15:17:50 [Info]Freedom: Opening connection to tcp:www.bjjs.gov.cn:80
2016/11/17 15:17:50 [Info]Dailing Raw TCP to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Socks: TCP Connect request to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]DefaultDispatcher: Taking detour [direct] for [tcp:www.bjjs.gov.cn:80].
2016/11/17 15:18:20 [Info]Socks: TCP Connect request to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]DefaultDispatcher: Taking detour [direct] for [tcp:www.bjjs.gov.cn:80].
2016/11/17 15:18:20 [Info]Socks: TCP Connect request to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]DefaultDispatcher: Taking detour [direct] for [tcp:www.bjjs.gov.cn:80].
2016/11/17 15:18:20 [Info]Socks: TCP Connect request to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]DefaultDispatcher: Taking detour [direct] for [tcp:www.bjjs.gov.cn:80].
2016/11/17 15:18:20 [Info]Freedom: Opening connection to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Dailing Raw TCP to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Freedom: Opening connection to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Dailing Raw TCP to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Freedom: Opening connection to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Dailing Raw TCP to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Freedom: Opening connection to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Dailing Raw TCP to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Socks: TCP Connect request to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]DefaultDispatcher: Taking detour [direct] for [tcp:www.bjjs.gov.cn:80].
2016/11/17 15:18:20 [Info]Freedom: Opening connection to tcp:www.bjjs.gov.cn:80
2016/11/17 15:18:20 [Info]Dailing Raw TCP to tcp:www.bjjs.gov.cn:80

客户端配置

{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "info"
  },
  "inbound": {
    "port": 6636,
    "protocol": "socks",
    "settings": {
      "auth": "noauth",
      "udp": false
    }
  },
  "outbound": {
    "protocol": "shadowsocks",
    "settings": {
      "servers": [
        {
          "address": "xxxxx",
          "port": xxxx,
          "method": "xxxx",
          "password": "xxxx",
          "ota": false
        }
      ]
    }
  },
  "inboundDetour": [
    {
      "protocol": "http",
      "port": 6646,
      "settings": {}
    }
  ],
  "outboundDetour": [
    {
      "protocol": "freedom",
      "tag": "direct",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "tag": "block",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "tag": "httpblock",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    },
    {
      "protocol": "shadowsocks",
      "tag": "default",
      "settings": {
        "servers": [
          {
            "address": "xxxxx",
            "port": xxx,
            "method": "xxxx",
            "password": "xxxxx",
            "ota": false
          }
        ]
      }
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "domain": [
            "gstatic.com",
            "jquery.com",
            "google.com",
            "youtube.com",
            "cloudflare.com",
            "atom.io"
          ],
          "outboundTag": "default"
        },
        {
          "type": "field",
          "domain": [
            "huaban.com"
          ],
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "domain": [
            "googleadservices.com",
            "googletagmanager.com",
            "api.share.baidu.com",
            "symcd.com",
            "acs86.com",
            "ad.unimhk.com",
            "adcome.cn",
            "adinfuse.com",
            "admaster.com.cn",
            "m.reachmax.cn",
            "cm.l.qq.com",
            "cms.gtags.net",
            "push.zhanzhang.baidu.com",
            "nsclick.baidu.com",
            "ads.genieessp.com",
            "ads.mobclix.com",
            "ads.mopub.com",
            "ads.yahoo.com",
            "adsage.cn",
            "adsage.com",
            "adsmogo",
            "adsmogo.org",
            "adview.cn",
            "adwhirl.com",
            "adwo.com",
            "agn.aty.sohu.com",
            "appads.com",
            "ark.letv.com",
            "beacon.qq.com",
            "cnzz.com",
            "crashlytics.com",
            "de.as.pptv.com",
            "domob.cn",
            "domob.org",
            "doubleclick.net",
            "duomeng.cn",
            "duomeng.net",
            "duomeng.org",
            "files.adform.net",
            "flurry.co",
            "googeadsserving.cn",
            "google-analytics.com",
            "googletagservices.com",
            "hm.baidu.com",
            "scorecardresearch.com",
            "ib.adnxs.com",
            "immob.cn",
            "init.icloud-analysis.com",
            "inmobi.com",
            "lives.l.qq.com",
            "logstat.t.sfht.com",
            "m.aty.sohu.com",
            "m.simaba.taobao.com",
            "mmstat.com",
            "mob.com",
            "mobads-logs.baidu.com",
            "mobads.baidu.com",
            "monitor.uu.qq.com",
            "n.mark.letv.com",
            "pingma.qq.com",
            "sax.sina.cn",
            "secure-ds.serving-sys.com",
            "smartadserver.com",
            "stat.m.jd.com",
            "stat.t.sfht.com",
            "s.360.cn",
            "tanx.com",
            "tapjoyads.com",
            "umeng.co",
            "umeng.com",
            "umtrack.com",
            "union.youdao.com",
            "uyunad.com",
            "youmi.net"
          ],
          "outboundTag": "httpblock"
        },
        {
          "type": "chinasites",
          "outboundTag": "direct"
        },
        {
          "type": "chinaip",
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "direct"
        }
      ]
    }
  },
  "transport": {
    "tcpSettings": {
      "connectionReuse": false
    }
  }
}
aRe00t commented 7 years ago

抓包看了下, 都是卡在 dns 解析环节了. v2ray 会同时查询AAAA和 A, 这个网站没有 AAAA 记录, 可能要回溯根服务器, 很久才收到 error. A的返回结果中是这样的, 没有该域名直接对应的 A 记录... www.bjjs.gov.cn. 194 IN CNAME www5.f5.bjjs.gov.cn. www5.f5.bjjs.gov.cn. 60 IN A 1.202.180.15

aRe00t commented 7 years ago

可能相关的问题: #257 #186

另外一个现象是: 停止访问 google.com 十几分钟后, 重新访问时会卡上1~3秒, 但之后的访问就很流畅了. 其他被墙网站有类似现象.

我的临时解决方案是: 把这些域名在 routing 中设置直接走 vps, 则不会出现这种情况.

由于还没学 go, 只大致从代码中看出, 这些问题可能产生于 dns 解析的耗时? 第一次解析的耗时会影响首次访问, ttl 过期后, 从缓存中剔除了解析结果. 所以再次访问时, 又会卡一下...

如果碰到 www.bjjs.gov.cn 这种 dns 设置不规范的网站, 会在 dns 阶段卡上很久.

我的临时解决方案是: 在 switchyomega 中设置常用的国内网站走直连, 剩余的走 v2ray.

chrome 解析 www.bjjs.gov.cn 挺快的, 不清楚是什么原理. 用curl, wget 访问 www.bjjs.gov.cn, 都能明显看到会在 dns 阶段卡上3秒, 但 v2ray 会卡上十几~30秒.

fcying commented 7 years ago

也有这个问题. 现在用meow 配合v2ray使用就正常了

ghost commented 7 years ago

560 一个可能的解决方案,缓解频繁出现的网页打不开的问题

DarienRaymond commented 6 years ago

DNS 的问题会在下一版本修复,对于 DNS 有问题的网站,从 V2Ray 的角度来说,也没什么办法