Shadowsocks-windows: frequent error when working with obfs-local - port is occupied

Created on 17 Oct 2017  ·  18Comments  ·  Source: shadowsocks/shadowsocks-windows

Version(release version or AppVeyor link)

shadowsocks-win 4.0.6

Environment(Operating system, .NET Framework, etc)

Windows 10 with .NET Framework 4.7

Steps you have tried

I config obfs-local support as instruction in #1368

Config and error log in detail (with all sensitive info masked)

Shadowsocks 错误: 端口已被占用
---------------------------
System.Exception: 端口已被占用

   在 Shadowsocks.Controller.Listener.Start(Configuration config)

   在 Shadowsocks.Controller.ShadowsocksController.Reload()
---------------------------
确定   
---------------------------

It works well every time when I just start it, but the error message below appears frequently when the process run for a while, especially when I want to switch to another server in my config. And every time when it appears, I need to stop the obfs-local.exe process in Task Manager and restart shadowsocks.exe to recover the service, which is really annoying.

Most helpful comment

我也有一样的问题。
我也在用simple_obfs_tls混淆方法来连接3个服务器,然后当我切换系统代理模式或者负载平衡模式时(本应有3个obfs-local进程)却奇妙地出现了第四个obfs-local进程,然后提示“端口被占用”。当我杀掉procexp里看到的第一个obfs-local进程时一切回归正常。
我个人认为是有一个obfs-local进程没有正确地被杀掉(毕竟每次切换服务器时都能看到3个obfs-local进程被杀掉然后3个obfs-local进程被调起)导致占用端口(给每个服务器指定local-port参数并不能解决问题)。
如需更多细节请务必回复。

All 18 comments

1324

I guess that's not the reason. Default local port 1080 haven't been used by any other process. The error only appeared when obfs-local is enabled in config, and it has never shown up at startup, but always appears when the service has run for a long while.

Could this problem be caused by SIP003 support? Wish log could be helpful:

[2017-10-17 02:06:40] Shadowsocks started
[2017-10-17 02:09:30] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3469 - PID: 9252
[2017-10-17 02:09:30] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 02:09:30] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 02:09:30] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 02:09:30] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 02:09:30] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 02:09:30] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3482 - PID: 17744
[2017-10-17 02:09:30] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3486 - PID: 18028
[2017-10-17 02:09:30] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3487 - PID: 17860
[2017-10-17 02:09:30] Shadowsocks started
[2017-10-17 02:10:24] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3709 - PID: 8360
[2017-10-17 02:10:24] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3714 - PID: 12376
[2017-10-17 02:10:24] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3715 - PID: 4752
[2017-10-17 02:10:24] Shadowsocks started
[2017-10-17 02:50:12] controller stopped
[2017-10-17 02:50:12] os suspend
[2017-10-17 10:06:52] os wake up
[2017-10-17 10:07:02] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:6322 - PID: 13216
[2017-10-17 10:07:02] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:6324 - PID: 23436
[2017-10-17 10:07:02] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:6325 - PID: 8520
[2017-10-17 10:07:02] Shadowsocks started
[2017-10-17 10:07:02] controller started
[2017-10-17 15:48:13] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 15:48:13] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 15:48:13] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 15:48:13] [E] Failed to start SIP003 plugin: 无法访问已释放的对象。
对象名:“Shadowsocks.Controller.Service.Sip003Plugin”。
[2017-10-17 15:48:13] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3063 - PID: 7696
[2017-10-17 15:48:14] Started SIP003 plugin for *.*.*.*:443 on 127.0.0.1:3071 - PID: 10048
[2017-10-17 15:48:14] Started SIP003 plugin for*.*.*.*:443 on 127.0.0.1:3072 - PID: 21832
[2017-10-17 15:48:14] System.Exception: 端口已被占用
   在 Shadowsocks.Controller.Listener.Start(Configuration config)
   在 Shadowsocks.Controller.ShadowsocksController.Reload()

I guess this issue happen on some slow computer ?
Please try put shadowsocks.exe and obfs-local.exe priority to Above Normal in Task Manager.

可能需要花点时间去调查

It seems that setting shadowsocks.exe and obfs-local.exe priority to Above Normal in Task Manager can temporarily improve this situation. But these settings will be lost every time after restarting, so it seems I need to repeat this action in each routine.

And other phenomenon is that every time when this error happened, there are four obfs-local.exe process in Task Manager, as I have only three servers configed with simple-obfs in gui-config.json. (And in usual case there only 3 process too.)

You can write a BAT (batch) file in shadowsocks.exe directory just one line:

START /ABOVENORMAL SHADOWSOCKS.EXE

When you want using shadowsocks, double-click the bat file.

@chenshaoju It seems starting shadowsocks.exe with /abovenormal won't keep obfs-local.exe being launched with priority "above normal". And unfortunately, I found this error can still happen even if I set all these process to "Above Normal".

@kongwy , how many servers in your server list with plug-ins?

@celeron533 Three.

i have encountered the same issue, it only appears when i change current server (with SIP003 plugin) to another server (which is using SIP003 too), and only appears when current using obfs-local.exe is doing mass data transfering (loading youtube or twitch), and when it happens, there will be one more obfs-local.exe in task manager.

在obfs处理数据时切换服务器或者切换代理模式(PAC/全局)的时候会出现这个问题,obfs-local.exe会有个别进程并未被重启驻留导致端口被占用。
我客户端内的服务器有七个。

@codexss 看样子是plugin的相关程序没有在第一时间被及时关闭

I'm the creator of #1533, I have ONLY one server on the list, so it may not be related to ss, but obfs-local

我也有一样的问题。
我也在用simple_obfs_tls混淆方法来连接3个服务器,然后当我切换系统代理模式或者负载平衡模式时(本应有3个obfs-local进程)却奇妙地出现了第四个obfs-local进程,然后提示“端口被占用”。当我杀掉procexp里看到的第一个obfs-local进程时一切回归正常。
我个人认为是有一个obfs-local进程没有正确地被杀掉(毕竟每次切换服务器时都能看到3个obfs-local进程被杀掉然后3个obfs-local进程被调起)导致占用端口(给每个服务器指定local-port参数并不能解决问题)。
如需更多细节请务必回复。

我遇到的这个错误是在 Listener.cs#L67 报的错,感觉不是obfs-local的问题,SIP003用的端口不是SS指定的随机空端口么。
#1618 把关闭插件放在关闭Socket之后,SS的Socket能正确关闭了,测试了两天没再遇到这个问题。
不知道这样能不能解决你们的问题。

其实simple-obfs去年11月份就release出来一个win32的执行文件,可以试一下
https://github.com/shadowsocks/simple-obfs/releases

Was this page helpful?
0 / 5 - 0 ratings