[GH-ISSUE #524] kcp做http代理时用户下载大文件会出现连接release 引起 read client http header err timeout #426

Closed
opened 2026-02-27 23:16:51 +03:00 by kerem · 4 comments
Owner

Originally created by @jzbg on GitHub (Feb 5, 2023).
Original GitHub issue: https://github.com/snail007/goproxy/issues/524

使用kcp协议做http代理时 用户浏览器下载大文件3分钟左右就会卡住,一级代理日志显示release 1分钟后 read client http header err timeout

Expected Behavior

期望使用kcp做http代理时,用户可以正常下载大文件 无论下载多长时间,即使速度慢也应该能够持续下载

Current Behavior

current 下载3分钟左右,一级代理就会release 之后提示http header timeout,并且中间会出现一段时间下载速度下降的情况,从20M下降到1.5M,1分钟后慢慢恢复。
http一级代理启动命令 和日志
./ proxy http - t kcp - p "1.0.1.8:6000" -- kcp- key mypaaaword -- kcp-mode ="fast3" -- kcp-mtu =1400 --kcp-method = none -- http - header - timeout =100000 -- http-timeout =30000 -- kcp-interval =300 -- kcp- sndwnd =204800

  • kcp - rcvwnd =204800 -- http-header- buffer =8192000
    2023/02/0509:32:13.153934 INPO kcp http ( s ) proxy on 1.0.1.8:6000
    2023/02/0509:32:18.094613 INPO GET :http://1.0.8.4/b
    2023/02/0509:32:18.094675 INPO use parent : false ,1.0.8.4:80
    2023/02/0509:32:18.095595 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 connected (1.0.8.4:80]
    2023/02/0509:34:17.295371 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 released [1.0.8.4:80]
    2023/02/0509:35:57.296650 WARN decoder error , from 1.5.1.100:53572, BRR : http decoder read err : read client http header err :timeout
    二级代理命令和日志
    [ rootelocelhoat proxy ]#./ proxy http - t tcp - p ":8081"- T kcp - P "1.0.1.8:6000"-- kcp - key mypaasword -- kcp - modem "fast3" -- kcp- mtu =1400 -- kcp - method = none -- http - header - timeout =10000 --http - timeout =30000 -- kcp - interval =300
  • -kcp - sndwnd =204800 -- kcp - rcvwnd -204800 -- http - header - buffer =8192000
    2023/02/0509:32:43.488183 INPO use kcp parent [1.0.1.8:6000][ ROUNDROBIN ]
    2023/02/0509:32:43.489174 INPO tcp http ( s ) proxy on (::]:8081
    2023/02/0509:32:44.123813 INPO GET :http://1.0.8.4/b
    2023/02/0509:32:44.123892 INPO use perent : true ,1.0.8.4:80
    2023/02/0509:32:44.127756 INPO Sonn 1.3.3.25:57384-1.5.1.100:8081<->0.0.0.0:53572-1.0.1.8:6000 connected [1.0.8.4:80]

Possible Solution

maybe 我的启动命令设置不对,目前不太明白kcp各个参数作用,自己设置的值是否会造成以上故障现象,此外有issues提示,将http-header-buffer的值调大,我从4096调到40960,扩大10倍,持续下载时间稍有延长,每次问题都在用户浏览器下载文件即将完成时发生,好像是下载文件的最后几个包一级代理认为已经发了,就release连接,但是二级代理并没收到,浏览器在等待,二级代理也在等待,而一级代理在等待二级代理回执消息的http header ,最终提示http header timeout

Steps to Reproduce

1.使用我的命令分别启动一级代理和二级代理
在用户侧,设置浏览器使用代理上网
下载文件
3分钟左右,下载失败
一级代理提示timeout

Context (Environment)

  1. proxy version is : v12.7
  2. full command is :
    一级
    proxy http - t kcp - p "1.0.1.8:6000" -- kcp- key mypaaaword -- kcp-mode ="fast3" -- kcp-mtu =1400 --kcp-method = none -- http - header - timeout =100000 -- http-timeout =30000 -- kcp-interval =300 -- kcp- sndwnd =204800
  • kcp - rcvwnd =204800 -- http-header- buffer =8192000
  • 二级
  • proxy http - t tcp - p ":8081"- T kcp - P "1.0.1.8:6000"-- kcp - key mypaasword -- kcp - modem "fast3" -- kcp- mtu =1400 -- kcp - method = none -- http - header - timeout =10000 --http - timeout =30000 -- kcp - interval =300
  • -kcp - sndwnd =204800 -- kcp - rcvwnd -204800 -- http - header - buffer =8192000
  1. system is :centos7
  2. full log is:
    一级日志
    ./ proxy http - t kcp - p "1.0.1.8:6000" -- kcp- key mypaaaword -- kcp-mode ="fast3" -- kcp-mtu =1400 --kcp-method = none -- http - header - timeout =100000 -- http-timeout =30000 -- kcp-interval =300 -- kcp- sndwnd =204800
  • kcp - rcvwnd =204800 -- http-header- buffer =8192000
    2023/02/0509:32:13.153934 INPO kcp http ( s ) proxy on 1.0.1.8:6000
    2023/02/0509:32:18.094613 INPO GET :http://1.0.8.4/b
    2023/02/0509:32:18.094675 INPO use parent : false ,1.0.8.4:80
    2023/02/0509:32:18.095595 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 connected (1.0.8.4:80]
    2023/02/0509:34:17.295371 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 released [1.0.8.4:80]
    2023/02/0509:35:57.296650 WARN decoder error , from 1.5.1.100:53572, BRR : http decoder read err : read client http header err :timeout
    二级代理命令和日志
    [ rootelocelhoat proxy ]#./ proxy http - t tcp - p ":8081"- T kcp - P "1.0.1.8:6000"-- kcp - key mypaasword -- kcp - modem "fast3" -- kcp- mtu =1400 -- kcp - method = none -- http - header - timeout =10000 --http - timeout =30000 -- kcp - interval =300
  • -kcp - sndwnd =204800 -- kcp - rcvwnd -204800 -- http - header - buffer =8192000
    2023/02/0509:32:43.488183 INPO use kcp parent [1.0.1.8:6000][ ROUNDROBIN ]
    2023/02/0509:32:43.489174 INPO tcp http ( s ) proxy on (::]:8081
    2023/02/0509:32:44.123813 INPO GET :http://1.0.8.4/b
    2023/02/0509:32:44.123892 INPO use perent : true ,1.0.8.4:80
    2023/02/0509:32:44.127756 INPO Sonn 1.3.3.25:57384-1.5.1.100:8081<->0.0.0.0:53572-1.0.1.8:6000 connected [1.0.8.4:80]

Detailed Description

使用kcp协议做http代理时,客户端浏览器下载大文件会失败,具体表现在一级代理提示client http header timeout,并且下载过程中会出现速度下降明显的情况

Possible Implementation

可能是我命令使用有问题,麻烦大佬解释一下kcp各个参数设置方法、含义,进一步观察,其实和http header timeout关系不大,应该是连接release引起的timeout,但是为啥连接会release呢,日志中看不出来。绕过代理,直接从服务器下载大文件,即使半小时也不会卡住,所以推测是一级代理连接原始web服务器的问题。

Originally created by @jzbg on GitHub (Feb 5, 2023). Original GitHub issue: https://github.com/snail007/goproxy/issues/524 <!--- Provide a general summary of the issue in the Title above --> 使用kcp协议做http代理时 用户浏览器下载大文件3分钟左右就会卡住,一级代理日志显示release 1分钟后 read client http header err timeout ## Expected Behavior 期望使用kcp做http代理时,用户可以正常下载大文件 无论下载多长时间,即使速度慢也应该能够持续下载 ## Current Behavior current 下载3分钟左右,一级代理就会release 之后提示http header timeout,并且中间会出现一段时间下载速度下降的情况,从20M下降到1.5M,1分钟后慢慢恢复。 http一级代理启动命令 和日志 ./ proxy http - t kcp - p "1.0.1.8:6000" -- kcp- key mypaaaword -- kcp-mode ="fast3" -- kcp-mtu =1400 --kcp-method = none -- http - header - timeout =100000 -- http-timeout =30000 -- kcp-interval =300 -- kcp- sndwnd =204800 - kcp - rcvwnd =204800 -- http-header- buffer =8192000 2023/02/0509:32:13.153934 INPO kcp http ( s ) proxy on 1.0.1.8:6000 2023/02/0509:32:18.094613 INPO GET :http://1.0.8.4/b 2023/02/0509:32:18.094675 INPO use parent : false ,1.0.8.4:80 2023/02/0509:32:18.095595 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 connected (1.0.8.4:80] 2023/02/0509:34:17.295371 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 released [1.0.8.4:80] 2023/02/0509:35:57.296650 WARN decoder error , from 1.5.1.100:53572, BRR : http decoder read err : read client http header err :timeout 二级代理命令和日志 [ rootelocelhoat proxy ]#./ proxy http - t tcp - p ":8081"- T kcp - P "1.0.1.8:6000"-- kcp - key mypaasword -- kcp - modem "fast3" -- kcp- mtu =1400 -- kcp - method = none -- http - header - timeout =10000 --http - timeout =30000 -- kcp - interval =300 - -kcp - sndwnd =204800 -- kcp - rcvwnd -204800 -- http - header - buffer =8192000 2023/02/0509:32:43.488183 INPO use kcp parent [1.0.1.8:6000][ ROUNDROBIN ] 2023/02/0509:32:43.489174 INPO tcp http ( s ) proxy on (::]:8081 2023/02/0509:32:44.123813 INPO GET :http://1.0.8.4/b 2023/02/0509:32:44.123892 INPO use perent : true ,1.0.8.4:80 2023/02/0509:32:44.127756 INPO Sonn 1.3.3.25:57384-1.5.1.100:8081<->0.0.0.0:53572-1.0.1.8:6000 connected [1.0.8.4:80] ## Possible Solution <!--- Not obligatory, but suggest a fix/reason for the bug, --> maybe 我的启动命令设置不对,目前不太明白kcp各个参数作用,自己设置的值是否会造成以上故障现象,此外有issues提示,将http-header-buffer的值调大,我从4096调到40960,扩大10倍,持续下载时间稍有延长,每次问题都在用户浏览器下载文件即将完成时发生,好像是下载文件的最后几个包一级代理认为已经发了,就release连接,但是二级代理并没收到,浏览器在等待,二级代理也在等待,而一级代理在等待二级代理回执消息的http header ,最终提示http header timeout ## Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug. Include code to reproduce, if relevant --> 1.使用我的命令分别启动一级代理和二级代理 在用户侧,设置浏览器使用代理上网 下载文件 3分钟左右,下载失败 一级代理提示timeout ## Context (Environment) <!--- How has this issue affected you? What are you trying to accomplish? --> <!--- Providing context helps us come up with a solution that is most useful in the real world --> 1. proxy version is : v12.7 1. full command is : 一级 proxy http - t kcp - p "1.0.1.8:6000" -- kcp- key mypaaaword -- kcp-mode ="fast3" -- kcp-mtu =1400 --kcp-method = none -- http - header - timeout =100000 -- http-timeout =30000 -- kcp-interval =300 -- kcp- sndwnd =204800 - kcp - rcvwnd =204800 -- http-header- buffer =8192000 - 二级 - proxy http - t tcp - p ":8081"- T kcp - P "1.0.1.8:6000"-- kcp - key mypaasword -- kcp - modem "fast3" -- kcp- mtu =1400 -- kcp - method = none -- http - header - timeout =10000 --http - timeout =30000 -- kcp - interval =300 - -kcp - sndwnd =204800 -- kcp - rcvwnd -204800 -- http - header - buffer =8192000 - 1. system is :centos7 1. full log is: 一级日志 ./ proxy http - t kcp - p "1.0.1.8:6000" -- kcp- key mypaaaword -- kcp-mode ="fast3" -- kcp-mtu =1400 --kcp-method = none -- http - header - timeout =100000 -- http-timeout =30000 -- kcp-interval =300 -- kcp- sndwnd =204800 - kcp - rcvwnd =204800 -- http-header- buffer =8192000 2023/02/0509:32:13.153934 INPO kcp http ( s ) proxy on 1.0.1.8:6000 2023/02/0509:32:18.094613 INPO GET :http://1.0.8.4/b 2023/02/0509:32:18.094675 INPO use parent : false ,1.0.8.4:80 2023/02/0509:32:18.095595 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 connected (1.0.8.4:80] 2023/02/0509:34:17.295371 INPO conn 1.5.1.100:53572-1.0.1.8:6000<->1.0.1.8:56724-1.0.8.4:80 released [1.0.8.4:80] 2023/02/0509:35:57.296650 WARN decoder error , from 1.5.1.100:53572, BRR : http decoder read err : read client http header err :timeout 二级代理命令和日志 [ rootelocelhoat proxy ]#./ proxy http - t tcp - p ":8081"- T kcp - P "1.0.1.8:6000"-- kcp - key mypaasword -- kcp - modem "fast3" -- kcp- mtu =1400 -- kcp - method = none -- http - header - timeout =10000 --http - timeout =30000 -- kcp - interval =300 - -kcp - sndwnd =204800 -- kcp - rcvwnd -204800 -- http - header - buffer =8192000 2023/02/0509:32:43.488183 INPO use kcp parent [1.0.1.8:6000][ ROUNDROBIN ] 2023/02/0509:32:43.489174 INPO tcp http ( s ) proxy on (::]:8081 2023/02/0509:32:44.123813 INPO GET :http://1.0.8.4/b 2023/02/0509:32:44.123892 INPO use perent : true ,1.0.8.4:80 2023/02/0509:32:44.127756 INPO Sonn 1.3.3.25:57384-1.5.1.100:8081<->0.0.0.0:53572-1.0.1.8:6000 connected [1.0.8.4:80] <!--- Provide a general summary of the issue in the Title above --> ## Detailed Description 使用kcp协议做http代理时,客户端浏览器下载大文件会失败,具体表现在一级代理提示client http header timeout,并且下载过程中会出现速度下降明显的情况 ## Possible Implementation <!--- Not obligatory, but suggest an idea for implementing addition or change --> 可能是我命令使用有问题,麻烦大佬解释一下kcp各个参数设置方法、含义,进一步观察,其实和http header timeout关系不大,应该是连接release引起的timeout,但是为啥连接会release呢,日志中看不出来。绕过代理,直接从服务器下载大文件,即使半小时也不会卡住,所以推测是一级代理连接原始web服务器的问题。
kerem 2026-02-27 23:16:51 +03:00
Author
Owner

@snail007 commented on GitHub (Feb 5, 2023):

kcp用的是这个https://github.com/xtaci/kcp-go ,没有做任何修改,你说的问题先看它是否有,它有的goproxy就一定有。使用参数含义和它官方一样。

<!-- gh-comment-id:1417960152 --> @snail007 commented on GitHub (Feb 5, 2023): kcp用的是这个https://github.com/xtaci/kcp-go ,没有做任何修改,你说的问题先看它是否有,它有的goproxy就一定有。使用参数含义和它官方一样。
Author
Owner

@jzbg commented on GitHub (Feb 7, 2023):

您好,我看了kcp-go 这个未实现tcp或者http代理,所以未做测试,但是找到了该作者的kcptun,实现了tcp通道,我用这个tcp通道串接ftp是可以连通的,但是goproxy的tcp通道使用kcp传输时,并不能联通ftp,所以,会不会是goproxy在调用kcp时有bug呢。

<!-- gh-comment-id:1419984628 --> @jzbg commented on GitHub (Feb 7, 2023): 您好,我看了kcp-go 这个未实现tcp或者http代理,所以未做测试,但是找到了该作者的kcptun,实现了tcp通道,我用这个tcp通道串接ftp是可以连通的,但是goproxy的tcp通道使用kcp传输时,并不能联通ftp,所以,会不会是goproxy在调用kcp时有bug呢。
Author
Owner

@jzbg commented on GitHub (Feb 7, 2023):

此外,kcp加速真的很棒,通过各种形式代理,可实现多场景加速,实测比一般tcp要快3-5倍

<!-- gh-comment-id:1419985700 --> @jzbg commented on GitHub (Feb 7, 2023): 此外,kcp加速真的很棒,通过各种形式代理,可实现多场景加速,实测比一般tcp要快3-5倍
Author
Owner

@jzbg commented on GitHub (Feb 10, 2023):

太棒了,我测试了12.8版本,代理后可以稳定浏览网站,可以稳定完成文件下载,之前的下载速度不稳定、文件下载失败的问题都解决了,下载下载特别快,大概有7倍左右的速度提升。

<!-- gh-comment-id:1425824835 --> @jzbg commented on GitHub (Feb 10, 2023): 太棒了,我测试了12.8版本,代理后可以稳定浏览网站,可以稳定完成文件下载,之前的下载速度不稳定、文件下载失败的问题都解决了,下载下载特别快,大概有7倍左右的速度提升。
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
starred/goproxy#426
No description provided.