[GH-ISSUE #382] Bridge server user traffic statistics is incorrect #259

Closed
opened 2026-10-31 20:10:42 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @pulsarice on GitHub (May 8, 2023).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/382

I have a bridge server in Iran and my users are all defined in this server.
the default outbound config of Iran server is Reality.

User ---Reality---> Iran Bridge Server ---Reality---> Foreign Server ---Freedom---> Free Internet

To troubleshoot I disabled all users except one and then downloaded 50mega bytes of data.
x-ui shows traffics like this:

image

As you see, user traffic is not correct.

Now if I delete the Reality outbound of Iran server and put a Freedom outbound in its place, the traffic will be calculated correctly. But of course now my Iran server is not forwarding user traffic to foreign server

User ---Reality---> Iran Bridge Server ---Freedom---> Iran Internet

image

This is my server config:

{
  "log": {
    "loglevel": "warning",
    "access": "./access.log",
    "error": "./error.log"
  },
  "api": {
    "tag": "api",
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ]
  },
  "inbounds": [
    {
      "tag": "api",
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      }
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "xxxxxxxxxx",
            "port": 443,
            "users": [
              {
                "id": "xxxxxxxxxx",
                "alterId": 0,
                "email": "t@t.tt",
                "security": "auto",
                "encryption": "none",
                "flow": "xtls-rprx-vision"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "reality",
        "realitySettings": {
          "serverName": "xxxxxxxxxx",
          "fingerprint": "firefox",
          "show": false,
          "publicKey": "xxxxxxxxxx",
          "shortId": "xxxxxxxxxx",
          "spiderX": "/xxxxxxxxxx"
        }
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "AsIs"
      }
    },
    {
      "tag": "blocked",
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "statsUserDownlink": true,
        "statsUserUplink": true
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "dns": {
    "servers": [
      {
        "address": "8.8.8.8"
      }
    ],
    "queryStrategy": "UseIPv4",
    "tag": "dns_inbound"
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      },
      {
        "type": "field",
        "outboundTag": "blocked",
        "domain": [
          "geosite:category-ir"
        ],
        "enabled": true
      },
      {
        "type": "field",
        "outboundTag": "blocked",
        "ip": [
          "geoip:ir"
        ],
        "enabled": true
      }
    ]
  },
  "stats": {}
}
Originally created by @pulsarice on GitHub (May 8, 2023). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/382 I have a bridge server in Iran and my users are all defined in this server. the default outbound config of Iran server is Reality. User ---Reality---> Iran Bridge Server ---Reality---> Foreign Server ---Freedom---> Free Internet To troubleshoot I disabled all users except one and then downloaded 50mega bytes of data. x-ui shows traffics like this: ![image](https://user-images.githubusercontent.com/5326305/236869264-e114eb0f-2090-4515-9188-3d543296a8a4.png) As you see, user traffic is not correct. Now if I delete the Reality outbound of Iran server and put a Freedom outbound in its place, the traffic will be calculated correctly. But of course now my Iran server is not forwarding user traffic to foreign server User ---Reality---> Iran Bridge Server ---Freedom---> Iran Internet ![image](https://user-images.githubusercontent.com/5326305/236869822-f30ec4f5-0fda-45ad-8009-a7c07a10d32c.png) This is my server config: ``` { "log": { "loglevel": "warning", "access": "./access.log", "error": "./error.log" }, "api": { "tag": "api", "services": [ "HandlerService", "LoggerService", "StatsService" ] }, "inbounds": [ { "tag": "api", "listen": "127.0.0.1", "port": 62789, "protocol": "dokodemo-door", "settings": { "address": "127.0.0.1" } } ], "outbounds": [ { "tag": "proxy", "protocol": "vless", "settings": { "vnext": [ { "address": "xxxxxxxxxx", "port": 443, "users": [ { "id": "xxxxxxxxxx", "alterId": 0, "email": "t@t.tt", "security": "auto", "encryption": "none", "flow": "xtls-rprx-vision" } ] } ] }, "streamSettings": { "network": "tcp", "security": "reality", "realitySettings": { "serverName": "xxxxxxxxxx", "fingerprint": "firefox", "show": false, "publicKey": "xxxxxxxxxx", "shortId": "xxxxxxxxxx", "spiderX": "/xxxxxxxxxx" } } }, { "tag": "direct", "protocol": "freedom", "settings": { "domainStrategy": "AsIs" } }, { "tag": "blocked", "protocol": "blackhole", "settings": { "response": { "type": "http" } } } ], "policy": { "levels": { "0": { "statsUserDownlink": true, "statsUserUplink": true } }, "system": { "statsInboundDownlink": true, "statsInboundUplink": true } }, "dns": { "servers": [ { "address": "8.8.8.8" } ], "queryStrategy": "UseIPv4", "tag": "dns_inbound" }, "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "inboundTag": [ "api" ], "outboundTag": "api", "type": "field" }, { "ip": [ "geoip:private" ], "outboundTag": "blocked", "type": "field" }, { "outboundTag": "blocked", "protocol": [ "bittorrent" ], "type": "field" }, { "type": "field", "outboundTag": "blocked", "domain": [ "geosite:category-ir" ], "enabled": true }, { "type": "field", "outboundTag": "blocked", "ip": [ "geoip:ir" ], "enabled": true } ] }, "stats": {} } ```
Author
Owner

@pulsarice commented on GitHub (May 8, 2023):

@alireza0 do you have any idea what's wrong?

<!-- gh-comment-id:1539051980 --> @pulsarice commented on GitHub (May 8, 2023): @alireza0 do you have any idea what's wrong?
Author
Owner

@alireza0 commented on GitHub (May 10, 2023):

@pulsarice
x-ui fetch statistics from xray-core and add them to the database.
Calculation is not on the shoulder of x-ui

<!-- gh-comment-id:1541834338 --> @alireza0 commented on GitHub (May 10, 2023): @pulsarice `x-ui` fetch statistics from `xray-core` and add them to the database. Calculation is not on the shoulder of `x-ui`
Author
Owner

@pulsarice commented on GitHub (May 10, 2023):

I changed the outbound protocol from Reality to VLESS-TCP-TLS-WS and the traffic measurement is done properly.
I wonder why outbound protocol has an effect on this!?

<!-- gh-comment-id:1542410603 --> @pulsarice commented on GitHub (May 10, 2023): I changed the **outbound** protocol from Reality to VLESS-TCP-TLS-WS and the traffic measurement is done properly. I wonder why outbound protocol has an effect on this!?
Author
Owner

@MHSanaei commented on GitHub (May 15, 2023):

https://t.me/panel3xui/65

<!-- gh-comment-id:1547324233 --> @MHSanaei commented on GitHub (May 15, 2023): https://t.me/panel3xui/65
Author
Owner

@psk007 commented on GitHub (Jun 27, 2025):

I'm having an issue with statistics: I tried testing different outbound types, but nothing changed. I suspect we have multiple connections, and the stats API might only consider some of them, not all. I also checked the provided Telegram link, but it seems the channel has changed. Can anyone help me solve this problem?

<!-- gh-comment-id:3012133846 --> @psk007 commented on GitHub (Jun 27, 2025): I'm having an issue with statistics: I tried testing different outbound types, but nothing changed. I suspect we have multiple connections, and the stats API might only consider some of them, not all. I also checked the provided Telegram link, but it seems the channel has changed. Can anyone help me solve this problem?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#259
No description provided.