Comments (43)
我把电脑客户端上又连去了另一台ss 服务器,再等了十分钟,手机那里还是上不去,完全没有释放的意思。所以我觉得应该不是客户端断开连接方式的问题。
from pysocket.
我在ss 服务器上把进程重启了一下,手机重新连上去了。这时候电脑就上不去了(good),然后手机断开以后,电脑上还是连不上去。错误信息还是相同。(not good)
from pysocket.
不知道我还有什么办法可以给出更多有用的日志吗?
from pysocket.
debug模式可以看到更多的日志,你可以用 python sever.py -v 开启。我的补丁的日志都会以[socket]开头。
另外你说的断开连接是指关闭浏览器还是关闭ss?
from pysocket.
不是关闭浏览器,
是断开ss连接,甚至还连了另一个ss server
from pysocket.
你试试关闭浏览器或关闭ss。某些浏览器会一直保持长连接,或一直尝试连接(即使你没打开网页)。
from pysocket.
@WalkerWalker
看了一下代码,我把所有的debug都注释掉了,所以你用debug模式也看不到更多的日志。
你再测一下吧,如果实在不行,就只能是调整规则,对指定时间无数据传输的连接进行强制关闭了。但我觉得这样可能会误伤,因为有长连接的存在。
from pysocket.
....我刚想说,我怎么没看到更多的日志
下面日志可以看到,我的一个连接原本在看youtube,11:39分断开,然后几乎啥也没发生,11:45分用手机连,一直都连不上,
2017-03-19 11:39:47 INFO connecting mtalk.google.com:5228 from 183.193.***.***:37074
2017-03-19 11:39:47 DEBUG hit cache: mtalk.google.com
2017-03-19 11:39:48 DEBUG destroy: yt3.ggpht.com:443
2017-03-19 11:39:48 DEBUG destroying remote
2017-03-19 11:39:48 DEBUG destroying local
2017-03-19 11:39:53 DEBUG destroy: www.youtube.com:443
2017-03-19 11:39:53 DEBUG destroying remote
2017-03-19 11:39:53 DEBUG destroying local
2017-03-19 11:39:55 DEBUG destroy: youtubei.youtube.com:443
2017-03-19 11:39:55 DEBUG destroying remote
2017-03-19 11:39:55 DEBUG destroying local
2017-03-19 11:39:55 DEBUG destroy: clients4.google.com:443
2017-03-19 11:39:55 DEBUG destroying remote
2017-03-19 11:39:55 DEBUG destroying local
2017-03-19 11:39:55 DEBUG destroy: s.youtube.com:443
2017-03-19 11:39:55 DEBUG destroying remote
2017-03-19 11:39:55 DEBUG destroying local
2017-03-19 11:39:55 DEBUG destroy: i.ytimg.com:443
2017-03-19 11:39:55 DEBUG destroying remote
2017-03-19 11:39:55 DEBUG destroying local
2017-03-19 11:39:55 DEBUG destroy: mtalk.google.com:5228
2017-03-19 11:39:55 DEBUG destroying remote
2017-03-19 11:39:55 DEBUG destroying local
2017-03-19 11:39:55 DEBUG destroy: r9---sn-n4v7kn76.googlevideo.com:443
2017-03-19 11:39:55 DEBUG destroying remote
2017-03-19 11:39:55 DEBUG destroying local
2017-03-19 11:39:55 DEBUG destroy: r9---sn-n4v7kn76.googlevideo.com:443
2017-03-19 11:39:55 DEBUG destroying remote
2017-03-19 11:39:55 DEBUG destroying local
2017-03-19 11:42:05 DEBUG 1 keys swept
2017-03-19 11:42:45 DEBUG 1 keys swept
2017-03-19 11:42:55 DEBUG 16 keys swept
2017-03-19 11:43:05 DEBUG 1 keys swept
2017-03-19 11:43:35 WARNING timed out: r7---sn-o097znel.googlevideo.com:443
2017-03-19 11:43:35 DEBUG already destroyed
2017-03-19 11:43:45 DEBUG 4 keys swept
2017-03-19 11:44:55 DEBUG 1 keys swept
2017-03-19 11:45:31 DEBUG accept
2017-03-19 11:45:31 ERROR [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:45:32 DEBUG accept
2017-03-19 11:45:35 DEBUG accept
2017-03-19 11:45:36 DEBUG accept
2017-03-19 11:45:44 DEBUG accept
2017-03-19 11:45:44 ERROR [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:45:48 DEBUG accept
2017-03-19 11:45:48 DEBUG accept
2017-03-19 11:45:49 DEBUG accept
2017-03-19 11:45:49 DEBUG accept
2017-03-19 11:45:49 DEBUG accept
2017-03-19 11:45:53 DEBUG accept
2017-03-19 11:46:15 DEBUG accept
2017-03-19 11:46:15 ERROR [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:46:15 DEBUG accept
2017-03-19 11:46:15 DEBUG accept
2017-03-19 11:46:17 DEBUG accept
2017-03-19 11:46:22 DEBUG accept
2017-03-19 11:46:22 DEBUG accept
2017-03-19 11:46:22 DEBUG accept
2017-03-19 11:46:27 DEBUG accept
2017-03-19 11:46:27 ERROR [socket] the server_addrs *:8333 client more then the 1
2017-03-19 11:46:27 DEBUG accept
2017-03-19 11:46:28 DEBUG accept
2017-03-19 11:46:28 DEBUG accept
2017-03-19 11:46:29 DEBUG accept
from pysocket.
嗯,时间小的话会误伤。时间大的话,每次切换设备都要等好久也是蛮蛋疼的。。。
不过为什么要关闭连接呢?
可不可以维护一个ip的集合,对指定时间无数据传输的连接,把那个ip从集合里挪出去。新的连接来了,再判断集合是不是满了,满了就拒绝,没满把ip加进集合。
from pysocket.
那就奇怪了,我比较想知道的是你有没有关闭浏览器或ss?关闭ss应该是会直接断开连接的,从我的测试来看,只有手机版的ss会出现关闭ss之后连接仍然存在的问题。或者你可以试着把 set_close_timeout 改成 True ?
我更新了一下代码,把logging.debug显示出来了,你再看看有没有更多的日志。
from pysocket.
如果不关闭连接的话那之前的设备仍然是可以上网的,只要那个连接存在。如果只是根据时间来判定的话可能会误伤一些长连接。
from pysocket.
我又测试了一下
https://gist.github.com/WalkerWalker/f349e086e0219a244733d0f00c73e17b
这次的log信息量多很多了!你看看能不能有帮助
我看到有70个add,35个close,是不是add两次是不应该的?如果拒绝的时候,能在log里面打出目前占用的连接,就更明确了。
from pysocket.
确实不应该出现两次同样地址和端口的add,一定是哪里出错了。
from pysocket.
但奇怪的是我这里一切正常。你用了两个端口还是只用了一个端口 ?有没有开负载均衡 ?按理说不管你怎么配置都不影响的,但还是先了解一下情况再说吧。
from pysocket.
这样,你先用其他客户端试一下,比如直接运行 local.py,先不要用shadowsocksX-NG。 我怀疑可能是shadowsocksX-NG 的连接跟别的客户端不一样。
另外我更新了一个 dev 分支,你试试看能不能解决你的问题
地址 :https://github.com/falseen/PySocket/tree/dev
git clone -b dev https://github.com/falseen/PySocket
from pysocket.
我突然在想会不会是因为我用了锐速来加速?我以前知道是有个没节操的双倍发包的算法,来减少丢包率的,但我没用那个。锐速不知道是不是同样的底层算法
那个没节操的叫做net-speeder,是会双倍发包的。锐速查了一下,似乎不是多倍发包的,网上似乎说是说不是的都有,好尴尬。我等下回去了看看关掉锐速是不是就没这个问题了。不过锐速真的能提速好多好多好多,超大区别
我刚刚试了一下听了锐速,还是有两个add,没差别。
from pysocket.
看来确实是客户端的关系。不过我用 shadowsocksX-NG 和手机上的 ssrconnect 都是如此,都有两个连续的一模一样的add,
运行哪个客户端好呢? local.py 是什么?
from pysocket.
先试一下常规的客户端会不会出现两个add,比如windows或安卓的客户端。或者你电脑上有python的话也可以直接运行 python local.py,跟sever.py的用法基本一致。
from pysocket.
或者你先试下dev版本
from pysocket.
dev 可以用,一看你的commit 我就觉得有戏。只加一次ip,干净对了
log在这里
https://gist.github.com/WalkerWalker/1fc1aa4fdd630f4be62bab14ac493c78
我是先在电脑上开了youtube,socket 建立 (line 5)
然后关了浏览器,都不用断vpn,socket就被干掉了 (line 119)
然后手机连上去,开了youtube,socket 建立 (line 127)
关了youtube应用,socket 也断了 (line 183)
后面发生的事情有点莫名其妙,大概是我电脑的某个进程突然开始访问google了,蛮奇怪的。。。先不管了,我等下再测试一下手机一边放youtube,一遍从4G切换成wifi,会是什么情况。
from pysocket.
但是这样可能会引起一些新的问题,还是要弄明白为什么会出现两次add。我比较想知道你用其他客户端会不会出现这个问题。如果不会的话,我看能不能找个苹果系统测试一下。因为我是用windows和安卓的,没用过苹果。
from pysocket.
那个基本测试成功了,没啥大问题。我手边也没有 windows 和 android。。。。你说的 local.py 是什么文件?
from pysocket.
跟server.py在同一个文件夹。dev 的代码是不完善的,还需要进一步处理。
from pysocket.
啊,这方面我不太懂
运行了 local.py 然后呢?
[root@ip-172-31-12-118 shadowsocks]# python local.py -c /etc/shadowsocks.json
INFO: loading config from /etc/shadowsocks.json
2017-03-19 18:18:39 INFO loading libsodium from libsodium.so.13
2017-03-19 18:18:39 INFO starting local at 127.0.0.1:1080
from pysocket.
设置浏览器的代理为 127.0.0.1:1080,类型 socks5。
from pysocket.
唔。。这对我来说有点太快了。我执行了下面几步
- 我是应该在我的aws ec2 上面是用老的socket.py (不会判断同一个ip只加一次),
- 跑同样的server
- 然后在mac上面,git clone下来shadowscoks项目,
- 然后在mac上面,配置和server一模一样的config.json,
- 运行local.py,参数是config.json
- 然后去另一个窗口运行下面的命令打开chrome
open -a /Applications/Google\ Chrome.app --args --proxy-server="socks5://127.0.0.1:1080":host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost"
- 访问youtube
但这样下来,并咩有什么反应,我的mac没有连接到ss服务器上。。。也没有什么地方报什么奇怪的错误信息
from pysocket.
不能跟config.json 一模一样的, local.py 的 config.json 的 server 选项要填你的服务器地址,其他的一样。
from pysocket.
哦哦,那个当然是填了服务器的地址,还是没用
from pysocket.
那就是你的代理没有设置成功,你直接在chrome里面设置代理吧。
from pysocket.
成功了!!刚刚我都要睡着想下个周末再弄了
https://gist.github.com/WalkerWalker/7c53659e5a08f9f4334d412ff366ba78
还是有两个add...
from pysocket.
那就真是怪事了。。。这不符合tcp/ip协议规范啊。。我先查一下,如果真的有这种情况的话我再修改下代码。
另外我想知道你的服务端是怎么配的,socket.py文件是直接放在shadowsocks目录中,没有放其他地方吧?
from pysocket.
对,socket.py放在和server.py同一个地方,一个字没改过,连参数都还没来得及改。当年网络课没好好学,什么tcp/ip, tcp,udp都不懂。。。靠你了啊
[centos@ip-172-31-12-118 shadowsocks]$ ls -la
总用量 332
drwxr-xr-x. 3 root root 4096 3月 19 20:45 .
drwxr-xr-x. 7 root root 4096 3月 19 09:21 ..
-rw-r--r--. 1 root root 17640 3月 19 09:21 asyncdns.py
-rw-r--r--. 1 root root 14377 3月 19 09:31 asyncdns.pyc
-rw-r--r--. 1 root root 9598 3月 19 09:21 common.py
-rw-r--r--. 1 root root 11290 3月 19 09:31 common.pyc
drwxr-xr-x. 2 root root 4096 3月 19 09:31 crypto
-rw-r--r--. 1 root root 6640 3月 19 09:21 cryptor.py
-rw-r--r--. 1 root root 7297 3月 19 09:31 cryptor.pyc
-rw-r--r--. 1 root root 5602 3月 19 09:21 daemon.py
-rw-r--r--. 1 root root 5458 3月 19 09:31 daemon.pyc
-rw-r--r--. 1 root root 7268 3月 19 09:21 eventloop.py
-rw-r--r--. 1 root root 9704 3月 19 09:31 eventloop.pyc
-rw-r--r--. 1 root root 686 3月 19 09:21 __init__.py
-rw-r--r--. 1 root root 300 3月 19 09:31 __init__.pyc
-rwxr-xr-x. 1 root root 2132 3月 19 09:21 local.py
-rw-r--r--. 1 root root 4286 3月 19 09:21 lru_cache.py
-rw-r--r--. 1 root root 4171 3月 19 09:31 lru_cache.pyc
-rw-r--r--. 1 root root 9816 3月 19 09:21 manager.py
-rw-r--r--. 1 root root 9307 3月 19 09:31 manager.pyc
-rwxr-xr-x. 1 root root 4882 3月 19 09:21 server.py
-rw-r--r--. 1 root root 17052 3月 19 09:21 shell.py
-rw-r--r--. 1 root root 15940 3月 19 09:31 shell.pyc
-rw-r--r--. 1 root root 9903 3月 19 20:45 socket.py
-rw-r--r--. 1 root root 6816 3月 19 20:45 socket.pyc
-rw-r--r--. 1 root root 35105 3月 19 09:21 tcprelay.py
-rw-r--r--. 1 root root 23675 3月 19 09:31 tcprelay.pyc
-rwxr-xr-x. 1 root root 2645 3月 19 09:21 tunnel.py
-rw-r--r--. 1 root root 14212 3月 19 09:21 udprelay.py
-rw-r--r--. 1 root root 9659 3月 19 09:31 udprelay.pyc
from pysocket.
啊,你放在这个目录了啊,我是想让你放shadowsocks根目录的,即有setup.py的目录。我当初测试的时候发现放shadowsocks/shadowsocks目录的话会出现一些意料之外的情况,我也不明白为什么会这样。但是放根目录就没问题。
from pysocket.
哦对了,我下午的时候傻傻以为两句add会不会一个是tcp一个是udp ,我去改了下log的语句,后来发现两个都是tcp
不过你大概肯定是知道的。
from pysocket.
。。。。这也能有差别?那我去换一下试试看
from pysocket.
还真的。。。只有一个add了
2017-03-19 22:03:25 INFO starting server at 172.31.12.118:8333
2017-03-19 22:03:25 DEBUG using event model: epoll
2017-03-19 22:03:26 DEBUG accept
2017-03-19 22:03:26 DEBUG [socket] add 13.124.***.***:31976
2017-03-19 22:03:26 INFO connecting chrome.google.com:443 from 13.124.***.***:31976
2017-03-19 22:03:26 DEBUG resolving chrome.google.com with type 1 using server 172.31.0.2
2017-03-19 22:03:27 DEBUG accept
2017-03-19 22:03:27 DEBUG [socket] add 13.124.***.***:31977
2017-03-19 22:03:27 INFO connecting live.github.com:443 from 13.124.***.***:31977
2017-03-19 22:03:27 DEBUG resolving live.github.com with type 1 using server 172.31.0.2
2017-03-19 22:03:28 DEBUG accept
2017-03-19 22:03:28 DEBUG [socket] add 13.124.***.***:31978
2017-03-19 22:03:28 INFO connecting live.github.com:443 from 13.124.***.***:31978
2017-03-19 22:03:28 DEBUG hit cache: live.github.com
2017-03-19 22:03:29 DEBUG destroy: live.github.com:443
2017-03-19 22:03:29 DEBUG destroying remote
2017-03-19 22:03:29 DEBUG destroying local
2017-03-19 22:03:29 DEBUG [socket] close the client socket 13.124.***.***:31977
2017-03-19 22:03:30 DEBUG accept
2017-03-19 22:03:30 DEBUG [socket] add 13.124.***.***:31980
2017-03-19 22:03:30 INFO connecting live.github.com:443 from 13.124.***.***:31980
2017-03-19 22:03:30 DEBUG hit cache: live.github.com
2017-03-19 22:03:34 DEBUG accept
2017-03-19 22:03:34 DEBUG [socket] add 13.124.***.***:31981
2017-03-19 22:03:34 INFO connecting live.github.com:443 from 13.124.***.***:31981
2017-03-19 22:03:34 DEBUG hit cache: live.github.com
2017-03-19 22:03:38 DEBUG accept
2017-03-19 22:03:38 DEBUG [socket] add 13.124.***.***:31982
2017-03-19 22:03:38 INFO connecting www.google.com:443 from 13.124.***.***:31982
2017-03-19 22:03:38 DEBUG resolving www.google.com with type 1 using server 172.31.0.2
2017-03-19 22:03:38 DEBUG accept
2017-03-19 22:03:38 DEBUG [socket] add 13.124.***.***:31983
2017-03-19 22:03:38 INFO connecting www.gstatic.com:443 from 13.124.***.***:31983
2017-03-19 22:03:38 DEBUG resolving www.gstatic.com with type 1 using server 172.31.0.2
2017-03-19 22:03:38 DEBUG accept
2017-03-19 22:03:38 DEBUG [socket] add 13.124.***.***:31984
2017-03-19 22:03:38 INFO connecting fonts.gstatic.com:443 from 13.124.***.***:31984
2017-03-19 22:03:38 DEBUG resolving fonts.gstatic.com with type 1 using server 172.31.0.2
2017-03-19 22:03:38 DEBUG accept
2017-03-19 22:03:38 DEBUG [socket] add 13.124.***.***:31985
2017-03-19 22:03:38 INFO connecting www.google.com:443 from 13.124.***.***:31985
2017-03-19 22:03:38 DEBUG hit cache: www.google.com
2017-03-19 22:03:38 DEBUG accept
2017-03-19 22:03:38 DEBUG [socket] add 13.124.***.***:31986
2017-03-19 22:03:38 INFO connecting www.google.com:443 from 13.124.***.***:31986
2017-03-19 22:03:38 DEBUG hit cache: www.google.com
2017-03-19 22:03:39 DEBUG accept
2017-03-19 22:03:39 DEBUG [socket] add 13.124.***.***:31987
2017-03-19 22:03:39 INFO connecting ip:80 from 13.124.***.***:31987
2017-03-19 22:03:39 DEBUG resolving ip with type 1 using server 172.31.0.2
2017-03-19 22:03:39 DEBUG resolving ip with type 28 using server 172.31.0.2
2017-03-19 22:03:39 ERROR unknown hostname ip when handling connection from 13.124.***.***:31987
2017-03-19 22:03:39 DEBUG destroy: ip:80
2017-03-19 22:03:39 DEBUG destroying local
2017-03-19 22:03:39 DEBUG [socket] close the client socket 13.124.***.***:31987
2017-03-19 22:03:43 DEBUG accept
2017-03-19 22:03:43 DEBUG [socket] add 13.124.***.***:31988
2017-03-19 22:03:43 INFO connecting facebook.com:443 from 13.124.***.***:31988
2017-03-19 22:03:43 DEBUG resolving facebook.com with type 1 using server 172.31.0.2
2017-03-19 22:03:43 DEBUG accept
2017-03-19 22:03:43 DEBUG [socket] add 13.124.***.***:31989
2017-03-19 22:03:43 INFO connecting www.facebook.com:443 from 13.124.***.***:31989
2017-03-19 22:03:43 DEBUG resolving www.facebook.com with type 1 using server 172.31.0.2
2017-03-19 22:03:45 DEBUG accept
2017-03-19 22:03:45 DEBUG [socket] add 13.124.***.***:31990
2017-03-19 22:03:45 INFO connecting clients1.google.com:443 from 13.124.***.***:31990
2017-03-19 22:03:45 DEBUG resolving clients1.google.com with type 1 using server 172.31.0.2
from pysocket.
那就对了!回头有空的时候再慢慢查一下为什么不能放子目录。你先这样用着吧。自定义端口的功能等会添加。
from pysocket.
嗯嗯好,辛苦你啦,陪着我瞎折腾!今天搞不动了,明天重新测一遍。。。
from pysocket.
请教下,两位说的shadowsocks根目录,我这边并没有shadowsocks/shadowsocks两层嵌套的目录。有一个shadowsocks-3.0.0-py2.6.egg的目录,貌似就是二位说的根目录,但是目录下没有setup.py文件。
from pysocket.
@yehaihuakai 你是用pip安装的。我们是直接下载的源码。
from pysocket.
@falseen 好的,谢谢
from pysocket.
falseen, 非常感谢你的项目,我和该楼主遇到了同样的问题,一个windows和Android设备。我服务器限制了同时只能登陆一个客户端。现在的情况是,我先用Android手机登陆是成功的,同时在windows设备上登陆,确实达到了限制的效果。但是问题来了,然后我在Android的ss客户端中关闭连接,然后退出SS客户端之后,windows设备怎么都连不上。我查看了log之后发现你这个socket.py程序还是提示我“client more than 1”。
我应该如何修改设置或者代码,才能达到正常的效果,Can you fix it, Thanks.
from pysocket.
老哥,你在吗?
15年的版本,限制同一端口连接数没有问题,能够随意切换,不过没有黑白名单功能,所以我试了下17年的版本,问题来了。
用自家网络连接(无论用什么设备和端口),断开后用邻居家网络(或4G)都无法连接原来的端口,重启后还是出现同样的问题。我怀疑是断开的ip地址没有清理成功。请问怎么改代码。。。在线等老哥。。。
from pysocket.
Related Issues (20)
- 希望支持多用户版的SS HOT 13
- proxy有说明文档吗 HOT 1
- 貌似udp有问题 HOT 10
- 用socket.py使XX-Net做ss的前置无效 HOT 1
- 在多账户系统下,黑名单内的端口无法使用 HOT 4
- 把socket.py放进去以后没有起作用 HOT 2
- 使用源码启动的SS服务器如何开机启动 HOT 1
- archlinux放置到/usr/lib/python3.6/site-packages/shadowsocks/ 不起作用 HOT 1
- 急急急,我是码盲。。。
- 搬瓦工系统自带ss,放在哪里? HOT 3
- 软件根目录在哪 HOT 3
- 黑白名单中如何添加一个范围内的端口
- 可以用在shadowsocks-manager上吗 HOT 1
- Limit Clients 如何使用? HOT 8
- 希望支持不同的port 有不同的限制数 HOT 2
- 【小问题】同一个设备,连着ss server播放Youtube,4G和wifi之间切换会出现中断
- 关于Limit_Clients udp 在 shadowsocks 下的bug。 HOT 3
- 大神好 hi能否给个联系方式
- 不支持SSR对吗? HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysocket.