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

服务端异常退出 "panic: concurrent write to websocket connection" #2975

Open
deadblue opened this issue Apr 16, 2024 · 1 comment
Open
Labels
bug Something isn't working upstream This problem is caused by upstream

Comments

@deadblue
Copy link

你正在使用哪个版本的 V2Ray?

服务端:v5.14.1
客户端:

  • PC: v5.14.1
  • 手机:v2rayNG v1.8.19 / 其他不明

你的使用场景是什么?

服务端是供几个朋友在一起用,在某一时刻出现 panic 后服务端挂掉,具体在做什么不清楚。

你看到的异常现象是什么?

服务端出现 panic 后非正常退出,监听的 Unix Domain Socket 没有被删除,导致 systemd 自动重启失败。

你期待看到的正常表现是怎样的?

不出现 panic,或出现 panic 后可正常删除 sock 文件再退出。

请附上你的配置

服务端配置:

{
  "log": {
    "access": {
      "type": "None"
    },
    "error": {
      "type": "Console",
      "level": "Info"
    }
  },

  "inbounds": [
    {
      "tag": "inbound-ws-trojan",
      "listen": "/tmp/v2ray-ws-trojan.sock",
      "protocol": "trojan",
      "settings": {
        "users": [
          "********-****-****-****-************"
        ]
      },
      "streamSettings": {
        "transport": "ws",
        "transportSettings": {
          "path": "/thi5_fi1e_n0t_3xis7s"
        },
        "security": "none"
      }
    }
  ],
  "outbounds": [{
    "tag": "outbound-direct",
    "protocol": "freedom"
  }, {
    "tag": "outbound-blackhole",
    "protocol": "blackhole"
  }],

  "router": {},
  "dns": {},
  "services": {
    "stats": {}
  }
}

客户端配置:

{
  "log": {
    "loglevel": "error"
  },
  "inbounds": [{
    "tag": "inbound-socks5",
    "port": 10808,
    "listen": "127.0.0.1",
    "protocol": "socks",
    "settings": {
      "udp": true
    },
    "sniffing": {
      "enabled": true,
      "destOverride": ["http", "tls"]
    }
  },
  {
    "tag": "inbound-http",
    "port": 10809,
    "listen": "0.0.0.0",
    "protocol": "http",
    "settings": {},
    "sniffing": {
      "enabled": true,
      "destOverride": ["http", "tls"]
    }
  }],

  "outbounds": [{
    "tag": "outbound-wss-trojan",
    "protocol": "trojan",
    "settings": {
      "servers": [{
        "address": "xxx.xxx.xxx",
        "port": xyxy,
        "password": "********-****-****-****-************"
      }]
    },
    "streamSettings": {
      "network": "ws",
      "security": "tls",
      "wsSettings": {
        "path": "/thi5_fi1e_n0t_3xis7s"
      },
      "tlsSettings": {
        "serverName": "xxx.xxx.xxx",
        "allowInsecure": false,
        "disableSystemRoot": true,
        "certificates": [{
          "usage": "verify",
          "certificate": [
            "-----BEGIN CERTIFICATE-----",
            "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "-----END CERTIFICATE-----"
          ]
        }]
      }
    }
  }, {
    "tag": "outbound-direct",
    "protocol": "freedom",
    "settings": {}
  }],

  "routing": {
    "domainStrategy": "AsIs",
    "domainMatcher": "mph",
    "rules": [{
      "type": "field",
      "ip": [
        "127.0.0.1",
        "10.0.0.0/8",
        "172.16.0.0/12",
        "192.168.0.0/16"
      ],
      "outboundTag": "outbound-direct"
    }]
  },

  "dns": {
    "servers": [
      "1.1.1.1",
      "8.8.8.8",
      "8.8.4.4",
      "localhost"
    ]
  },

  "policy": {}
}

请附上出错时软件输出的错误日志

服务器端错误日志:

见 journal 日志。

客户端错误日志:

N/A

请附上访问日志

N/A

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

nginx 配置文件:

// upstream-v2ray.conf
upstream v2ray_ws_trojan {
    server unix:/tmp/v2ray-ws-trojan.sock;
}

// server-v2ray.conf
server {
    listen  xxxx-yyyy ssl http2;

    server_name xxx.xxx.xxx;

    server_tokens off;
    charset utf-8;

    ssl_certificate     /var/miku/etc/ssl/xxx-cert.pem;
    ssl_certificate_key /var/miku/etc/ssl/xxx-key.pem;

    location ^~ /thi5_fi1e_n0t_3xis7s {
        proxy_pass http://v2ray_ws_trojan;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

    location / {
        root  /var/miku/www/xxx;
        index index.html;
    }
}

如果 V2Ray 无法启动,请附上 --test 命令的输出

如果 V2Ray 服务运行异常,请附上 journal 日志:

v2ray[11989]: panic: concurrent write to websocket connection
v2ray[11989]: goroutine 4619702 [running]:
v2ray[11989]: github.com/gorilla/websocket.(*messageWriter).flushFrame(0xc00068bc90, 0x1, {0xc00097e02b?, 0x853a8d?, 0x0?})
v2ray[11989]:         github.com/gorilla/websocket@v1.5.1/conn.go:632 +0x4b8
v2ray[11989]: github.com/gorilla/websocket.(*Conn).WriteMessage(0xc00056f340, 0xc00068bd10?, {0xc00097e000, 0x2b, 0x800})
v2ray[11989]:         github.com/gorilla/websocket@v1.5.1/conn.go:785 +0x126
v2ray[11989]: github.com/v2fly/v2ray-core/v5/transport/internet/websocket.(*connection).Write(0x2?, {0xc00097e000?, 0x2b, 0x17aa2e8?})
v2ray[11989]:         github.com/v2fly/v2ray-core/v5/transport/internet/websocket/connection.go:125 +0x1b1
v2ray[11989]: github.com/v2fly/v2ray-core/v5/proxy/trojan.(*PacketWriter).writePacket(0xc0008f5920, {0xc000291000, 0x20, 0x40adba?}, {{0x17aa2e8?, 0xc00027fd7c?}, 0xd810?, 0xc0?})
v2ray[11989]:         github.com/v2fly/v2ray-core/v5/proxy/trojan/protocol.go:181 +0x49c
v2ray[11989]: github.com/v2fly/v2ray-core/v5/proxy/trojan.(*PacketWriter).WriteMultiBufferWithMetadata(0xc0008f5920, {0xc00068bec8, 0x1, 0xc00032e008?}, {{0x17aa2e8?, 0xc00027fd7c?}, 0x0?, 0x0?})
v2ray[11989]:         github.com/v2fly/v2ray-core/v5/proxy/trojan/protocol.go:131 +0xbf
v2ray[11989]: github.com/v2fly/v2ray-core/v5/proxy/trojan.(*Server).handleUDPPayload.func1({0x17aa208, 0xc0007fd720}, 0x1?)
v2ray[11989]:         github.com/v2fly/v2ray-core/v5/proxy/trojan/server.go:219 +0x5a
v2ray[11989]: github.com/v2fly/v2ray-core/v5/transport/internet/udp.handleInput({0x17aa208, 0xc0007fd720}, 0xc00068bfd0?, {{0x17aa2e8?, 0xc00027fd7c?}, 0x5924?, 0x0?}, 0xc000376be0)
v2ray[11989]:         github.com/v2fly/v2ray-core/v5/transport/internet/udp/dispatcher_split.go:119 +0x266
v2ray[11989]: created by github.com/v2fly/v2ray-core/v5/transport/internet/udp.(*Dispatcher).getInboundRay in goroutine 4619672
v2ray[11989]:         github.com/v2fly/v2ray-core/v5/transport/internet/udp/dispatcher_split.go:80 +0x4cb
systemd[1]: v2ray.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
@AkinoKaede AkinoKaede added the bug Something isn't working label Apr 17, 2024
@AkinoKaede
Copy link
Contributor

This problem seems caused by upstream. gorilla/websocket#828

@AkinoKaede AkinoKaede added the upstream This problem is caused by upstream label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream This problem is caused by upstream
Projects
None yet
Development

No branches or pull requests

2 participants