Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

balancer 不工作,从第一个 outbounds 出去了, #2777

Closed
Uhtred009 opened this issue Dec 2, 2023 · 8 comments
Closed

balancer 不工作,从第一个 outbounds 出去了, #2777

Uhtred009 opened this issue Dec 2, 2023 · 8 comments

Comments

@Uhtred009
Copy link

{
"log": {
"access": "",
"error": "./error.log",
"loglevel": "warning"
},
"inbounds": [
{
"tag": "socks",
"port": 7889,
"listen": "127.0.0.1",
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"auth": "noauth",
"udp": true,
"allowTransparent": false
}
},
{
"tag": "http",
"port": 7890,
"listen": "127.0.0.1",
"protocol": "http",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"auth": "noauth",
"udp": true,
"allowTransparent": false
}
}
],
"outbounds": [

{
  "tag": "tw11",
  "protocol": "vmess",
  "settings": {
    "vnext": [
      {
        "address": "11.xxx.com",
        "port": 443,
        "users": [
          {
            "id": "xxx",
            "alterId": 0,
            "email": "t@t.tt",
            "security": "auto"
          }
        ]
      }
    ]
  },
  "streamSettings": {
    "network": "ws",
    "security": "tls",
    "tlsSettings": {
      "allowInsecure": false,
      "serverName": "11.xxx.com"
    },
    "wsSettings": {
      "path": "/fb",
      "headers": {
        "Host": "11.xxx.com"
      }
    }
  },
  "mux": {
    "enabled": false,
    "concurrency": -1
  }
},

{
  "tag": "test11",
  "protocol": "vless",
  "settings": {
    "vnext": [
      {
        "address": "57.xxx.com",
        "port": 10443,
        "users": [
          {
            "id": "xxx",
            "alterId": 0,
            "email": "t@t.tt",
            "security": "auto",
            "encryption": "none",
            "flow": "xtls-rprx-vision"
          }
        ]
      }
    ]
  },
  "streamSettings": {
    "network": "tcp",
    "security": "tls",
    "tlsSettings": {
      "allowInsecure": false
    }
  },
  "mux": {
    "enabled": false,
    "concurrency": -1
  }
},
{
  "tag": "direct",
  "protocol": "freedom",
  "settings": {}
},
{
  "tag": "block",
  "protocol": "blackhole",
  "settings": {
    "response": {
      "type": "http"
    }
  }
}

],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [

  {
    "type": "field",
    "inboundTag": [
      "api"
    ],
    "outboundTag": "api",
    "enabled": true
  },
 
  {
    "id": "4994401533470426702",
    "type": "field",
    "outboundTag": "block",
    "domain": [
      "geosite:category-ads-all"
    ],
    "enabled": true
  },
  {
    "id": "5079714562843255463",
    "type": "field",
    "outboundTag": "direct",
    "domain": [
      "geosite:cn"
    ],
    "enabled": true
  },
  {
    "id": "5059010412196119074",
    "type": "field",
    "outboundTag": "direct",
    "ip": [
      "geoip:private",
      "geoip:cn"
    ],
    "enabled": true
  },
  {
    "id": "5696708702475119467",
    "type": "field",
    "port": "0-65535",
    "balancerTag": "balancer11",
    "enabled": true
  }
],

"balancers": [{
  "tag": "balancer11",
  "selector": [
    "test11",
    "tw11"
  ],
  "strategy": {
    "type": "leastPing"
  }
 
}]

},

"observatory": {
"subjectSelector":[
"balancer11"
],
"probeURL": "https://api.github.com/_private/browser/stats",
"probeInterval": "1s"
}

}

能够成功启动,但是balancer 不工作,访问直接从第一个 outbounds 出去了, 请问下 是我的配置有问题吗,还是说xray 就没有这个功能?

@yomnxkcs
Copy link

yomnxkcs commented Dec 2, 2023

配置好复杂有点看不懂,下面这个配置是干什么用的?

{
  "routing": {
    "balancers": [
      {
        "strategy": {
          "type": "leastPing"  // 这里没看懂
        }
      }
    ]
  }
}

然后这里也没看懂,为什么填balancer的tag而不是outbound的tag?

{
  "observatory": {
    "subjectSelector": [
      "balancer11" // 这里
    ]
  }
}

@us254
Copy link

us254 commented Dec 2, 2023

the configuration issue lies in the incorrect use of tags within the JSON configuration. The "balancerTag" in the routing rule and the "subjectSelector" in the "observatory" section should both be set to the tag of the load balancer, not the outbound tag. This mismatch is likely the cause of the balancer not functioning correctly. Correcting these tags to point to the load balancer should resolve the issue.

@Uhtred009
Copy link
Author

配置好复杂有点看不懂,下面这个配置是干什么用的?

{
  "routing": {
    "balancers": [
      {
        "strategy": {
          "type": "leastPing"  // 这里没看懂
        }
      }
    ]
  }
}

然后这里也没看懂,为什么填balancer的tag而不是outbound的tag?

{
  "observatory": {
    "subjectSelector": [
      "balancer11" // 这里
    ]
  }
}

这个是 负载均衡的一种配置,选取最快速的outbounds 出口

@Uhtred009
Copy link
Author

the configuration issue lies in the incorrect use of tags within the JSON configuration. The "balancerTag" in the routing rule and the "subjectSelector" in the "observatory" section should both be set to the tag of the load balancer, not the outbound tag. This mismatch is likely the cause of the balancer not functioning correctly. Correcting these tags to point to the load balancer should resolve the issue.

"balancers": [{
"tag": "balancer11",
"selector": [
"test11",
"tw11"
],
"strategy": {
"type": "leastPing"
}

}]
"balancers": [{
"tag": "balancer11",
"selector": [
"test11",
"tw11"
],
"strategy": {
"type": "leastPing"
}

}] 我都设置的是 负载均衡的出口 balancer11, 应该是没有错吧 ,检查了好几遍

@us254
Copy link

us254 commented Dec 2, 2023

#1146

@yomnxkcs
Copy link

yomnxkcs commented Dec 3, 2023

是的你在observatory填了balancer的tag,但是为什么填balancer的tag?根据文档https://www.v2fly.org/config/observatory.html#observatoryobject应该填outbound的tag啊。

然后leastPing的问题,我们来模拟一下它的运行过程。假设tw11测出来是0.123,test11测出来是0.456,那选tw11作为出口没问题啊。然后下一轮再测出tw11是0.234,test11测出来还是0.456,现在又一次选tw11作为出口也没问题啊。当然这只是模拟,实际运行情况可能不是这样。

最后建议在遇到问题的时候先把loglevel设置成debug。

@Fangliding
Copy link
Member

@yomnxkcs v2ray core的东西 xray这边没有来着

@Uhtred009
Copy link
Author

@yomnxkcs 确实如此,搞定了,感谢! longlive xray-core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants