V2ray-core: 经常 accept4: too many open files

Created on 9 Dec 2017  ·  6Comments  ·  Source: v2ray/v2ray-core

1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明)
V2Ray v2.51 (One for all) 20171123

2) 你的使用场景是什么?比如使用 Chrome 通过 Socks/VMess 代理观看 YouTube 视频。
路由器使用ss-redir转到 v2ray开的ss端口

3) 你看到的不正常的现象是什么?(请描述具体现象,比如访问超时,TLS 证书错误等)
2017/12/09 23:43:00 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp 0.0.0.0:5600: accept4: too many open files] > Retry: all retry attempts failed

4) 你期待看到的正确表现是怎样的?
不要一直报错,看起来好像是连接不够用了,但是不知道原因。

5) 请附上你的配置(提交 Issue 前请隐藏服务器端IP地址)。

服务器端配置:
{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbound": {
    "port": 29758,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "f9e5f1ad-04ea-4697-a74c-13bb7ad74933",
          "level": 1,
          "alterId": 64,
          "email": "[email protected]"
        }
      ]
    },
    "streamSettings": {
        "security": "",
        "tlsSettings": {},
        "wsSettings": null,
        "network": "tcp",
        "kcpSettings": null,
        "tcpSettings": {
            "header": {
                "request": {
                    "path": [
                        "/"
                    ],
                    "version": "1.1",
                    "method": "GET",
                    "headers": {
                        "Host": "bing.com",
                        "Connection": [
                            "keep-alive"
                        ],
                        "Accept-Encoding": [
                            "gzip, deflate"
                        ],
                        "Pragma": "no-cache",
                        "User-Agent": [
                            "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36",
                            "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
                        ]
                    }
                },
                "type": "http",
                "response": {
                    "status": "200",
                    "headers": {
                        "Transfer-Encoding": [
                            "chunked"
                        ],
                        "Connection": [
                            "keep-alive"
                        ],
                        "Content-Type": [
                            "application/octet-stream",
                            "video/mpeg"
                        ],
                        "Pragma": "no-cache"
                    },
                    "reason": "OK",
                    "version": "1.1"
                }
            },
            "connectionReuse": true
        }
    }
  },
  "outbound": {
    "protocol": "freedom",
    "settings": {}
  },
  "outboundDetour": [
    {
        "protocol": "freedom",
        "settings": null,
        "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "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": "blocked"
        }
      ]
    }
  }
}
客户端配置:
{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbound": {
    "port": 29758,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "f9e5f1ad-04ea-4697-a74c-13bb7ad74933",
          "level": 1,
          "alterId": 64,
          "email": "[email protected]"
        }
      ]
    },
    "streamSettings": {
      "security": "",
      "tlsSettings": {},
      "wsSettings": null,
      "network": "tcp",
      "kcpSettings": null,
      "tcpSettings": {
        "header": {
          "request": {
            "path": [
              "/"
            ],
            "version": "1.1",
            "method": "GET",
            "headers": {
              "Host": "bing.com",
              "Connection": [
                "keep-alive"
              ],
              "Accept-Encoding": [
                "gzip, deflate"
              ],
              "Pragma": "no-cache",
              "User-Agent": [
                "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36",
                "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
              ]
            }
          },
          "type": "http",
          "response": {
            "status": "200",
            "headers": {
              "Transfer-Encoding": [
                "chunked"
              ],
              "Connection": [
                "keep-alive"
              ],
              "Content-Type": [
                "application/octet-stream",
                "video/mpeg"
              ],
              "Pragma": "no-cache"
            },
            "reason": "OK",
            "version": "1.1"
          }
        },
        "connectionReuse": true
      }
    }
  },
  "outbound": {
    "protocol": "vmess",
    "streamSettings": {
      "network": "tcp",
      "tcpSettings": {
        "connectionReuse": true,
        "header": {
          "type": "http"
        }
      }
    },
    "settings": {
      "vnext": [
        {
          "address": "1.1.1.1",
          "port": 29758,
          "users": [
            {
              "id": "f9e5f1ad-04ea-4697-a74c-13bb7ad74933",
              "alterId": 64,
              "email": "[email protected]",
              "security": "aes-128-cfb"
            }
          ]
        },
        {
          "address": "1.1.1.1",
          "port": 29758,
          "users": [
            {
              "id": "f9e5f1ad-04ea-4697-a74c-13bb7ad74933",
              "alterId": 64,
              "email": "[email protected]",
              "security": "aes-128-cfb"
            }
          ]
        }
      ]
    },
    "mux": {
      "enabled": true
    }
  },
  "inboundDetour": [
    {
      "protocol": "shadowsocks",
      "port": 5500,
      "tag": "in_vmess_us",
      "settings": {
        "method": "aes-256-cfb",
        "password": "mogo1234",
        "udp": true,
        "level": 1
      }
    },
    {
      "protocol": "shadowsocks",
      "port": 5600,
      "tag": "in_vmess_google",
      "settings": {
        "method": "aes-256-cfb",
        "password": "mogo1234",
        "udp": true,
        "level": 1
      }
    }
  ],
  "outboundDetour": [
    {
      "protocol": "freedom",
      "tag": "direct",
      "settings": null
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "protocol": "vmess",
      "tag": "out_vmess_us",
      "streamSettings": {
        "network": "tcp",
        "tcpSettings": {
          "connectionReuse": true,
          "header": {
            "type": "http"
          }
        }
      },
      "settings": {
        "vnext": [
          {
            "address": "1.1.1.1",
            "port": 29758,
            "users": [
              {
                "id": "f9e5f1ad-04ea-4697-a74c-13bb7ad74933",
                "alterId": 64,
                "email": "[email protected]",
                "security": "aes-128-cfb"
              }
            ]
          }
        ]
      },
      "mux": {
        "enabled": true
      }
    },
    {
      "protocol": "vmess",
      "tag": "out_vmess_google",
      "streamSettings": {
        "network": "tcp",
        "tcpSettings": {
          "connectionReuse": true,
          "header": {
            "type": "http"
          }
        }
      },
      "settings": {
        "vnext": [
          {
            "address": "1.1.1.1",
            "port": 29758,
            "users": [
              {
                "id": "f9e5f1ad-04ea-4697-a74c-13bb7ad74933",
                "alterId": 64,
                "email": "[email protected]",
                "security": "aes-128-cfb"
              }
            ]
          }
        ]
      },
      "mux": {
        "enabled": true
      }
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPOnDemand",
      "rules": [
        {
          "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": "blocked"
        },
        {
          "type": "chinaip",
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "inboundTag": [
            "in_vmess_google"
          ],
          "outboundTag": "out_vmess_google"
        },
        {
          "type": "field",
          "inboundTag": [
            "in_vmess_us"
          ],
          "outboundTag": "out_vmess_us"
        }
      ]
    }
  }
}

6) 请附上出错时软件输出的错误日志。在 Linux 中,日志通常在 /var/log/v2ray/error.log 文件中。

服务器端错误日志:
2017/12/09 02:00:49 [Warning]Core: V2Ray started
2017/12/09 10:06:31 [Warning]App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: connection ends > Proxy|VMess|Inbound: failed to transfer request > Crypto: size too large 51114
2017/12/09 21:24:28 [Warning]App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: connection ends > Proxy|VMess|Inbound: failed to transfer request > Crypto: size too large 54544
客户端错误日志:
2017/12/09 23:49:44 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp 0.0.0.0:5600: accept4: too many open files] > Retry: all retry attempts failed
2017/12/09 23:49:44 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp 0.0.0.0:5500: accept4: too many open files] > Retry: all retry attempts failed
2017/12/09 23:49:46 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp 0.0.0.0:5500: accept4: too many open files] > Retry: all retry attempts failed
2017/12/09 23:50:27 [Warning]failed to handler mux client connection > Proxy|VMess|Outbound: connection ends > context canceled

7) 请附上访问日志。在 Linux 中,日志通常在 /var/log/v2ray/access.log 文件中。

2017/12/09 23:24:41 61.171.153.246:20740 accepted tcp:v1.mux.cool:9527
2017/12/09 23:26:18 61.171.153.246:23062 accepted tcp:v1.mux.cool:9527
2017/12/09 23:36:04 61.171.153.246:42310 accepted tcp:v1.mux.cool:9527
2017/12/09 23:36:24 61.171.153.246:42588 accepted tcp:v1.mux.cool:9527
2017/12/09 23:40:15 61.171.153.246:45748 accepted tcp:v1.mux.cool:9527
2017/12/09 23:40:15 61.171.153.246:45750 accepted tcp:v1.mux.cool:9527
2017/12/09 23:40:52 61.171.153.246:46836 accepted tcp:v1.mux.cool:9527
2017/12/09 23:45:19 61.171.153.246:52874 accepted tcp:v1.mux.cool:9527
2017/12/09 23:45:48 61.171.153.246:54290 accepted tcp:v1.mux.cool:9527
2017/12/09 23:53:48 61.171.153.246:64382 accepted tcp:v1.mux.cool:9527

8) 其它相关的配置文件(如 Nginx)和相关日志。

请预览一下你填的内容再提交。

Most helpful comment

在 v2ray.service 文件的 [Service] 下一行加一句 LimitNOFILE=102400

All 6 comments

在 v2ray.service 文件的 [Service] 下一行加一句 LimitNOFILE=102400

@ToutyRater 哥们,这个v2ray.service在vps的哪个地方啊?

@man2018

sudo vim /etc/systemd/system/v2ray.service
sudo systemctl daemon-reload
sudo systemctl restart v2ray

@zhaoyibo 谢谢哥们。目前v2我已经没有任何问题了

为什么我的vps没有/etc/systemd/system/v2ray.service 这个文件,我使用的centos 6.1。需要我自己创建这个文件吗? @zhaoyibo

@xtea
6使用sysvinit
7使用systemd

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahdung picture ahdung  ·  3Comments

ghost picture ghost  ·  4Comments

nielspeen picture nielspeen  ·  4Comments

ToutyRater picture ToutyRater  ·  4Comments

vonhezhou picture vonhezhou  ·  4Comments