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

无法开机启动 #103

Closed
liwei19920307 opened this issue Aug 29, 2016 · 30 comments
Closed

无法开机启动 #103

liwei19920307 opened this issue Aug 29, 2016 · 30 comments
Labels
Milestone

Comments

@liwei19920307
Copy link

添加到开机自启后 日志显示connection refused,但是直接执行却是正常的。

@fatedier
Copy link
Owner

不是很理解,能提供详细的系统环境和日志吗?

@fatedier fatedier changed the title 无法开启启动 无法开机启动 Aug 29, 2016
@liwei19920307
Copy link
Author

liwei19920307 commented Aug 29, 2016

gmial截图回复 github没显示 我就贴部分错误了 xxxxxx 均为打码

你好 我服务器是centos frps配置如下

[common]
bind_addr = 0.0.0.0
bind_port = xxxxxxx
vhost_http_port = 80
vhost_https_port = 443
dashboard_port = xxxxxx
#log_file = /root/frps/frps.log
log_level = info
log_max_days = 3
privilege_mode = true
privilege_token = xxxx
#privilege_allow_ports = 2000-3000,3001,3003,4000-50000
#max_pool_count = 100

​frpc部分配置
[common]
server_addr =xxxxxx
server_port = 66
#log_file = /home/pi/Kevin/frpc/frpc.log
#log_level = info
#log_max_days = 3
auth_token = xxxxxx
privilege_token = xxxxxxx
#use_encryption = true
#use_gzip = true

[xxxxx]
privilege_mode = true
custom_domains = xxxxxx
type = http
local_ip = 127.0.0.1
local_port = 80
.....

​我在/etc/init.d/添加了这个服务rc.loacl我也试过了

#!/bin/sh

### BEGIN INIT INFO
# Provides:          frpc
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start frpc
# Description:       start frpc
### END INIT INFO

case $1 in
        start)
                /home/pi/Kevin/frpc/frpc -c /home/pi/Kevin/frpc/frpc.ini > /home/pi/log
                ;;
        stop)
                killall frpc
                ;;
        restart)
                $0 stop
                sleep 2
                $0 start
                ;;
*)
echo "Usage: $0 (start|stop|restart)"
;;

esac

exit 0

​自启动后日志如下

2016/08/29 19:50:33 [main.go:109] [I] Start frpc success
2016/08/29 19:50:33 [control.go:135] [E] ProxyName [kevin], connect to server [lxxxxxx] error, lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read: connection refused
2016/08/29 19:50:33 [control.go:39] [E] ProxyName [kevin], connect to server failed!
2016/08/29 19:50:33 [control.go:135] [E] ProxyName [kssh], connect to server [lxxxxxxx] error, lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read: connection refused
2016/08/29 19:50:33 [control.go:39] [E] ProxyName [kssh], connect to server failed!
2016/08/29 19:50:33 [control.go:135] [E] ProxyName [wiki], connect to server [xxxxxxx] error, lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read: connection refused
2016/08/29 19:50:33 [control.go:39] [E] ProxyName [wiki], connect to server failed!
2016/08/29 19:50:33 [control.go:135] [E] ProxyName [rpc], connect to server [xxxx] error, lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read: connection refused
2016/08/29 19:50:33 [control.go:39] [E] ProxyName [rpc], connect to server failed!
2016/08/29 19:50:33 [control.go:135] [E] ProxyName [ssh], connect to server [xxxxx] error, lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read: connection refused
省略类似的。。。
2016/08/29 19:50:33 [control.go:39] [E] ProxyName [demo], connect to server failed!
2016/08/29 19:50:33 [main.go:112] [W] All proxy exit!

但是正常手动运行是正常的没有任何问题
/home/pi/Kevin/frpc/frpc -c /home/pi/Kevin/frpc/frpc.ini 没有任何问题

2016-08-29 20:35 GMT+08:00 fatedier notifications@github.com:

不是很理解,能提供详细的系统环境和日志吗?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#103 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AK88wa7iWZSz0LCw73pyfdNv-VWbH5tKks5qktIYgaJpZM4Jvamc
.

@liwei19920307
Copy link
Author

忘记说了 我的客户端是debian树莓派跑的 我在单位的ubuntu上也试了不行 不知道是我那写错了吗

2016-08-29 20:35 GMT+08:00 fatedier notifications@github.com:

不是很理解,能提供详细的系统环境和日志吗?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#103 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AK88wa7iWZSz0LCw73pyfdNv-VWbH5tKks5qktIYgaJpZM4Jvamc
.

@fatedier
Copy link
Owner

看起来是 dns 解析的问题,你可以换成 ip 试试。另外你的 /etc/resolv.conf 里是怎么配的?

@liwei19920307
Copy link
Author

pi@liwei:~/Kevin/frpc $ cat /etc/resolv.conf

Generated by resolvconf

domain lan
nameserver 192.168.2.1

DNS我没动 不支持域名吗 那为什么手动启动可以 我试了IP 还是相同的错误

2016-08-29 22:34 GMT+08:00 fatedier notifications@github.com:

看起来是 dns 解析的问题,你可以换成 ip 试试。另外你的 /etc/resolv.conf 里是怎么配的?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#103 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AK88wTYhpluTWtBjHn53QD9VqCoj2sIZks5qku3sgaJpZM4Jvamc
.

@fatedier
Copy link
Owner

lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read: connection refused

这里服务器的 liwei.gq 换成 ip 还是相同的错误?具体是什么原因我也不是很清楚,但是看起来就是 frpc 要连接 frps,然后你 server 地址填的是 liwei.gq,而解析这个域名时查询的是本地的 ipv6 的 53 端口,结果这个端口并没有启用,所以返回了 connection refused

@liwei19920307
Copy link
Author

对 换成frpc换成对应IP还是相同错误 但是手动启动依然可以 那我试着关闭ipv6试试看 谢谢

2016-08-29 22:51 GMT+08:00 fatedier notifications@github.com:

lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read:
connection refused

这里服务器的 liwei.gq 换成 ip 还是相同的错误?具体是什么原因我也不是很清楚,但是看起来就是 frpc 要连接 frps,然后你
server 地址填的是 liwei.gq,而解析这个域名时查询的是本地的 ipv6 的 53 端口,结果这个端口并没有启用,所以返回了 connection
refused。


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#103 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AK88wbnUNRZ9FryaUsH4qh9armR-zijJks5qkvHpgaJpZM4Jvamc
.

@liwei19920307
Copy link
Author

我刚才看了下 我VPS并没有启动IPV6 我明天试下centos自启frpc

在 2016年8月29日 下午10:53,Kevin Li liwei19920307@gmail.com写道:

对 换成frpc换成对应IP还是相同错误 但是手动启动依然可以 那我试着关闭ipv6试试看 谢谢

2016-08-29 22:51 GMT+08:00 fatedier notifications@github.com:

lookup liwei.gq on [::1]:53: read udp [::1]:33730->[::1]:53: read:
connection refused

这里服务器的 liwei.gq 换成 ip 还是相同的错误?具体是什么原因我也不是很清楚,但是看起来就是 frpc 要连接 frps,然后你
server 地址填的是 liwei.gq,而解析这个域名时查询的是本地的 ipv6 的 53 端口,结果这个端口并没有启用,所以返回了 connection
refused。


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#103 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AK88wbnUNRZ9FryaUsH4qh9armR-zijJks5qkvHpgaJpZM4Jvamc
.

@fatedier
Copy link
Owner

我不是很理解为什么换成 ip 了之后还会遇到查询 dns 的错误,可能还有一些隐藏的其他问题。

@Coande
Copy link

Coande commented Sep 11, 2016

同是树莓派,无论编辑rc.local还是添加到init.d,都无法启动frpc。手动启动没有问题。

@liwei19920307
Copy link
Author

Debian下应该都有这个问题,目前我是延迟启动解决的就是sleep 60秒 然后启动frpc就没问题,至少10秒

@Coande
Copy link

Coande commented Sep 11, 2016

果然,sleep 10秒就可以了。THS

@ghsa1994
Copy link

楼主你的树莓派可以开机自启动了吗?我的同样是树莓派平台客户端无法开机自启动,试过各种办法,服务端在搬瓦工的Centos 6 x86可以重启自启动

@liwei19920307
Copy link
Author

在你的启动脚本之前填上sleep 10 例如:
sleep 10
.../frps -c ../frpc.ini

@ghsa1994
Copy link

谢谢,现在已经可以正常开机运行了,frp速度很快,比花生壳好多了

@orangeshu
Copy link

我是个新手。想请问为啥要延迟10秒啊?对于ubuntu系统也可以吗?

@ghsa1994
Copy link

自己试验一下 估计是等待加载什么服务之后再启动frp客户端才有效 Linux各平台都不一样 自己试验一下

@orangeshu
Copy link

好的,谢谢!

@cercky
Copy link

cercky commented Jan 16, 2017

我将# Default-Start: 2 3 4 5 修改成了# Default-Start: 3 4 5 去掉无网络环境启动 可以正常工作,前提是fprs可正常链接。

据我观察是fprc不支持无连接启动 和无网络启动, 如果可以的话请增加在这2种模式下fprc不退出的机制。

@fatedier fatedier added this to the v0.11 milestone May 31, 2017
@fatedier
Copy link
Owner

fatedier commented Jun 1, 2017

0.11.0 版本 frpc 新增了 log_fail_exit 配置项,如果为 false,则启动失败不会退出。

@fatedier fatedier closed this as completed Jun 1, 2017
@yanfeng42
Copy link

@fatedier 只发现了 login_fail_exit = true, 把这个改为 false 可以解决问题.即:
在frpc.ini [common]配置下,添加
login_fail_exit = false 验证可以解决树莓派无法重启自动启动 frpc 的问题

@astbl123
Copy link

@ios122 如果ubuntu加了这句“login_fail_exit = false”会导致系统无法启动,因为网络没准备好,系统一直卡在frp那里。

@yanfeng42
Copy link

@astbl123 我的并没有卡在这里;我看这里的日志,类似于一个失败后,自动重试的策略;日志中,有多次尝试连接的记录; 估计和其他配置项 也有关系;

@liwei19920307
Copy link
Author

liwei19920307 commented Dec 18, 2017

个人知道的frp正常运行需要两个条件:1.能联网2.服务器时间和客户端时间正确
1.网络可以通过After=network.target

[Unit]
Description=frpc
After=network.target ntpdate.service

[Service]
Type=simple
User=root
PIDFile=/var/run/frpc.pid
ExecStart=/home/oi/Kevin/frp/frpc -c /home/oi/Kevin/frp/frpc.ini
Restart=on-failure
RestartSec=15s

[Install]
WantedBy=multi-user.target

2.时间可以After=ntpdate.service,ntpdate.service是我自己写的一个开机服务用来开机时对时,系统需要安装ntpdate,这样log_fail_exit配置项都不需要加

[Unit]
Description=ntpdate
After=network.target

[Service]
Type=simple
User=root
PIDFile=/var/run/ntpdate.pid
ExecStart=/usr/sbin/ntpdate time.windows.com
Restart=on-failure
RestartSec=15s

[Install]
WantedBy=multi-user.target

@astbl123
Copy link

@liwei19920307 请问你的是脚本还是什么?看不懂这些配置。

@astbl123
Copy link

@ios122 如果不加“login_fail_exit = false”,就会尝试一次后退出,日志如下:
2017/12/18 16:37:12 [W] [control.go:121] login to server failed: dial tcp x.x.x.x:7000: connect: network is unreachable
dial tcp x.x.x.x:7000: connect: network is unreachable

@liwei19920307
Copy link
Author

@astbl123 systemd的脚本

@PHCSJC
Copy link

PHCSJC commented Dec 25, 2018

@ios122 如果ubuntu加了这句“login_fail_exit = false”会导致系统无法启动,因为网络没准备好,系统一直卡在frp那里。

放到后台就不会卡系统了
nohup frpc -c frpc.ini &

@keyne-wang
Copy link

@ios122 如果ubuntu加了这句“login_fail_exit = false”会导致系统无法启动,因为网络没准备好,系统一直卡在frp那里。

放到后台就不会卡系统了
nohup frpc -c frpc.ini &

这个放到哪里啊?

@kouk1014
Copy link

kouk1014 commented May 9, 2022

如果是用的chkconfig做的启动脚本,要看下启动顺序,就脚本第二行 #chkconfig: 2345 80 90 ,第二个数字,network的优先权是10,如果这个脚本的优先权也是10 就会出现网络还没启动好链接失败的问题, 改成大点的数例如80就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests