-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
VLESS over http/2 模式下,客户端运行一段时间后就无法正常工作 #289
Comments
是的 我也遇到了 目前暂时切换到v2ray core使用 |
Diffdiff --git a/http/config.go b/http/config.go
index 0000000..1111111 100644
--- a/http/config.go
+++ b/http/config.go
@@ -1,11 +1,9 @@
-// +build !confonly
-
package http
import (
- "github.com/v2fly/v2ray-core/v4/common"
- "github.com/v2fly/v2ray-core/v4/common/dice"
- "github.com/v2fly/v2ray-core/v4/transport/internet"
+ "github.com/xtls/xray-core/common"
+ "github.com/xtls/xray-core/common/dice"
+ "github.com/xtls/xray-core/transport/internet"
)
const protocolName = "http"
diff --git a/http/config.pb.go b/http/config.pb.go
index 718c00f..94b7d43 100644
--- a/http/config.pb.go
+++ b/http/config.pb.go
@@ -85,21 +85,20 @@ var File_transport_internet_http_config_proto protoreflect.FileDescriptor
var file_transport_internet_http_config_proto_rawDesc = []byte{
0x0a, 0x24, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65,
0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f,
- 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74,
- 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x22, 0x30, 0x0a, 0x06, 0x43, 0x6f,
- 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03,
- 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68,
- 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x42, 0x87, 0x01, 0x0a,
- 0x26, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e,
- 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
- 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75,
- 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x32, 0x66, 0x6c, 0x79, 0x2f, 0x76, 0x32, 0x72, 0x61,
- 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x34, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70,
- 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74,
- 0x70, 0xaa, 0x02, 0x22, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54,
- 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65,
- 0x74, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61,
+ 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e,
+ 0x68, 0x74, 0x74, 0x70, 0x22, 0x30, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12,
+ 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f,
+ 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
+ 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x42, 0x76, 0x0a, 0x20, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72,
+ 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74,
+ 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69,
+ 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72,
+ 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72,
+ 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0xaa,
+ 0x02, 0x1c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74,
+ 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -116,7 +115,7 @@ func file_transport_internet_http_config_proto_rawDescGZIP() []byte {
var file_transport_internet_http_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_transport_internet_http_config_proto_goTypes = []interface{}{
- (*Config)(nil), // 0: v2ray.core.transport.internet.http.Config
+ (*Config)(nil), // 0: xray.transport.internet.http.Config
}
var file_transport_internet_http_config_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
diff --git a/http/config.proto b/http/config.proto
index 874c5a9..34433af 100644
--- a/http/config.proto
+++ b/http/config.proto
@@ -1,9 +1,9 @@
syntax = "proto3";
-package v2ray.core.transport.internet.http;
-option csharp_namespace = "V2Ray.Core.Transport.Internet.Http";
-option go_package = "github.com/v2fly/v2ray-core/v4/transport/internet/http";
-option java_package = "com.v2ray.core.transport.internet.http";
+package xray.transport.internet.http;
+option csharp_namespace = "Xray.Transport.Internet.Http";
+option go_package = "github.com/xtls/xray-core/transport/internet/http";
+option java_package = "com.xray.transport.internet.http";
option java_multiple_files = true;
message Config {
diff --git a/http/dialer.go b/http/dialer.go
index 08ae989..2255b9f 100644
--- a/http/dialer.go
+++ b/http/dialer.go
@@ -1,5 +1,3 @@
-// +build !confonly
-
package http
import (
@@ -9,14 +7,14 @@ import (
"net/url"
"sync"
+ "github.com/xtls/xray-core/common"
+ "github.com/xtls/xray-core/common/buf"
+ "github.com/xtls/xray-core/common/net"
+ "github.com/xtls/xray-core/common/net/cnc"
+ "github.com/xtls/xray-core/transport/internet"
+ "github.com/xtls/xray-core/transport/internet/tls"
+ "github.com/xtls/xray-core/transport/pipe"
"golang.org/x/net/http2"
-
- "github.com/v2fly/v2ray-core/v4/common"
- "github.com/v2fly/v2ray-core/v4/common/buf"
- "github.com/v2fly/v2ray-core/v4/common/net"
- "github.com/v2fly/v2ray-core/v4/transport/internet"
- "github.com/v2fly/v2ray-core/v4/transport/internet/tls"
- "github.com/v2fly/v2ray-core/v4/transport/pipe"
)
var (
@@ -24,7 +22,7 @@ var (
globalDialerAccess sync.Mutex
)
-func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.Config) *http.Client {
+func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.Config) (*http.Client, error) {
globalDialerAccess.Lock()
defer globalDialerAccess.Unlock()
@@ -33,7 +31,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.C
}
if client, found := globalDialerMap[dest]; found {
- return client
+ return client, nil
}
transport := &http2.Transport{
@@ -69,6 +67,9 @@ func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.C
if p := state.NegotiatedProtocol; p != http2.NextProtoTLS {
return nil, newError("http2: unexpected ALPN protocol " + p + "; want q" + http2.NextProtoTLS).AtError()
}
+ if !state.NegotiatedProtocolIsMutual {
+ return nil, newError("http2: could not negotiate protocol mutually").AtError()
+ }
return cn, nil
},
TLSClientConfig: tlsSettings.GetTLSConfig(tls.WithDestination(dest)),
@@ -79,7 +80,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.C
}
globalDialerMap[dest] = client
- return client
+ return client, nil
}
// Dial dials a new TCP connection to the given destination.
@@ -89,7 +90,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
if tlsConfig == nil {
return nil, newError("TLS must be enabled for http transport.").AtWarning()
}
- client := getHTTPClient(ctx, dest, tlsConfig)
+ client, err := getHTTPClient(ctx, dest, tlsConfig)
+ if err != nil {
+ return nil, err
+ }
opts := pipe.OptionsFromContext(ctx)
preader, pwriter := pipe.New(opts...)
@@ -111,7 +115,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
// Disable any compression method from server.
request.Header.Set("Accept-Encoding", "identity")
- response, err := client.Do(request) // nolint: bodyclose
+ response, err := client.Do(request)
if err != nil {
return nil, newError("failed to dial to ", dest).Base(err).AtWarning()
}
@@ -121,10 +125,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
bwriter := buf.NewBufferedWriter(pwriter)
common.Must(bwriter.SetBuffered(false))
- return net.NewConnection(
- net.ConnectionOutput(response.Body),
- net.ConnectionInput(bwriter),
- net.ConnectionOnClose(common.ChainedClosable{breader, bwriter, response.Body}),
+ return cnc.NewConnection(
+ cnc.ConnectionOutput(response.Body),
+ cnc.ConnectionInput(bwriter),
+ cnc.ConnectionOnClose(common.ChainedClosable{breader, bwriter, response.Body}),
), nil
}
diff --git a/http/errors.generated.go b/http/errors.generated.go
index bbaec46..f004816 100644
--- a/http/errors.generated.go
+++ b/http/errors.generated.go
@@ -1,6 +1,6 @@
package http
-import "github.com/v2fly/v2ray-core/v4/common/errors"
+import "github.com/xtls/xray-core/common/errors"
type errPathObjHolder struct{}
diff --git a/http/http.go b/http/http.go
index 0ef5118..3c0d015 100644
--- a/http/http.go
+++ b/http/http.go
@@ -1,3 +1,3 @@
package http
-//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
+//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
diff --git a/http/http_test.go b/http/http_test.go
index 5657748..ca1d9f2 100644
--- a/http/http_test.go
+++ b/http/http_test.go
@@ -8,14 +8,14 @@ import (
"github.com/google/go-cmp/cmp"
- "github.com/v2fly/v2ray-core/v4/common"
- "github.com/v2fly/v2ray-core/v4/common/buf"
- "github.com/v2fly/v2ray-core/v4/common/net"
- "github.com/v2fly/v2ray-core/v4/common/protocol/tls/cert"
- "github.com/v2fly/v2ray-core/v4/testing/servers/tcp"
- "github.com/v2fly/v2ray-core/v4/transport/internet"
- . "github.com/v2fly/v2ray-core/v4/transport/internet/http"
- "github.com/v2fly/v2ray-core/v4/transport/internet/tls"
+ "github.com/xtls/xray-core/common"
+ "github.com/xtls/xray-core/common/buf"
+ "github.com/xtls/xray-core/common/net"
+ "github.com/xtls/xray-core/common/protocol/tls/cert"
+ "github.com/xtls/xray-core/testing/servers/tcp"
+ "github.com/xtls/xray-core/transport/internet"
+ . "github.com/xtls/xray-core/transport/internet/http"
+ "github.com/xtls/xray-core/transport/internet/tls"
)
func TestHTTPConnection(t *testing.T) {
@@ -26,7 +26,7 @@ func TestHTTPConnection(t *testing.T) {
ProtocolSettings: &Config{},
SecurityType: "tls",
SecuritySettings: &tls.Config{
- Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.v2fly.org")))},
+ Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))},
},
}, func(conn internet.Connection) {
go func() {
@@ -56,7 +56,7 @@ func TestHTTPConnection(t *testing.T) {
ProtocolSettings: &Config{},
SecurityType: "tls",
SecuritySettings: &tls.Config{
- ServerName: "www.v2fly.org",
+ ServerName: "www.example.com",
AllowInsecure: true,
},
})
diff --git a/http/hub.go b/http/hub.go
index f1bc841..de20b63 100644
--- a/http/hub.go
+++ b/http/hub.go
@@ -1,5 +1,3 @@
-// +build !confonly
-
package http
import (
@@ -12,14 +10,15 @@ import (
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
- "github.com/v2fly/v2ray-core/v4/common"
- "github.com/v2fly/v2ray-core/v4/common/net"
- http_proto "github.com/v2fly/v2ray-core/v4/common/protocol/http"
- "github.com/v2fly/v2ray-core/v4/common/serial"
- "github.com/v2fly/v2ray-core/v4/common/session"
- "github.com/v2fly/v2ray-core/v4/common/signal/done"
- "github.com/v2fly/v2ray-core/v4/transport/internet"
- "github.com/v2fly/v2ray-core/v4/transport/internet/tls"
+ "github.com/xtls/xray-core/common"
+ "github.com/xtls/xray-core/common/net"
+ "github.com/xtls/xray-core/common/net/cnc"
+ http_proto "github.com/xtls/xray-core/common/protocol/http"
+ "github.com/xtls/xray-core/common/serial"
+ "github.com/xtls/xray-core/common/session"
+ "github.com/xtls/xray-core/common/signal/done"
+ "github.com/xtls/xray-core/transport/internet"
+ "github.com/xtls/xray-core/transport/internet/tls"
)
type Listener struct {
@@ -96,12 +95,12 @@ func (l *Listener) ServeHTTP(writer http.ResponseWriter, request *http.Request)
}
done := done.New()
- conn := net.NewConnection(
- net.ConnectionOutput(request.Body),
- net.ConnectionInput(flushWriter{w: writer, d: done}),
- net.ConnectionOnClose(common.ChainedClosable{done, request.Body}),
- net.ConnectionLocalAddr(l.Addr()),
- net.ConnectionRemoteAddr(remoteAddr),
+ conn := cnc.NewConnection(
+ cnc.ConnectionOutput(request.Body),
+ cnc.ConnectionInput(flushWriter{w: writer, d: done}),
+ cnc.ConnectionOnClose(common.ChainedClosable{done, request.Body}),
+ cnc.ConnectionLocalAddr(l.Addr()),
+ cnc.ConnectionRemoteAddr(remoteAddr),
)
l.handler(conn)
<-done.Wait()
|
h2传家宝式bug ,同一wifi多ap,ap之间切换,或者wifi/移动数据之间切换也出这个问题。tcp就不会 |
主要是Xray与v2ray的h2传输方式无自动恢复连接或保持。一旦网络短暂断开,需要客户端再手动连接恢复。 |
Revert #79 试试? |
麻烦 @JimhHan 研究一下 |
似乎是因为没有指定 |
@elvisw @lw4free @xianren78 @lxhao61 |
这个我没法试啊,我用NG比较方便测试网络改变导致的断线。二进制只能用路由器上,没有root手机 |
试着用github action编译了一份:https://github.com/elvisw/Xray-core/actions/runs/598403225 |
@JimhHan 问题似乎没有改善,我再观察一下 |
还是同样的问题 客户端日志
|
感谢反馈,本地测试已经没有问题了。 |
@JimhHan 我用openWRT x64也是一样的情况。不会是我Github Actions编译流程设置的有问题导致没有编译正确吧 |
@JimhHan 是的,之前已经发现了。 |
我这边目前测试没有问题 |
This comment has been minimized.
This comment has been minimized.
十分感谢帮忙测试 |
已测试,替换客户端文件后问题解决。 |
感谢各位的测试与反馈 |
感谢开发大神们的辛勤付出. |
超时,网络问题,并非bug。 |
应该不是,此日志太频繁了。一般不超过一分钟就产生几个。 |
已确定为网络问题。 |
好吧,反正不影响使用。只是同台服务器,非h2传输应用从不产生上述日志,仅h2传输应用不断产生。 |
* https://github.com/XTLS/Xray-core: Fix available mux picker in reverse portal (XTLS#274) Fix XTLS#289 (XTLS#300) Fix XTLS#320
整个配置思路参考了 https://github.com/XTLS/Xray-examples/tree/main/VLESS-H2C-Caddy2
服务端是通过Caddy2反向代理了VLESS over h2c,客户端为VLESS over http/2。客户端启动后正常运行一段时间后(大约在1小时以内),就无法正常工作(无法通过xray访问网站),并输出日志
2021/02/20 10:19:13 [Warning] [4163186524] app/proxyman/outbound: failed to process outbound traffic > proxy/vless/outbound: failed to find an available destination > common/retry: [transport/internet/http: failed to dial to tcp:127.0.0.1:10221 > Put "https://127.0.0.1:10221/path/": dial tcp 127.0.0.1:10221: operation was canceled] > common/retry: all retry attempts failed
。必须重启客户端后才能暂时恢复正常xray服务端配置
服务端使用了Caddy2反向代理到443端口(https),
xray客户端配置
由于测试并输出日志时客户端在内网,在streamSettings是ws或者h2时,v2ray不支持前置代理,因此使用了dokodemo-door进行了桥接。但是可以确定,在外网环境客户端直连,一样会出这个问题。
服务端日志
客户端日志
The text was updated successfully, but these errors were encountered: