我有一个服务,它将在启动后侦听端口8443。 我已将xinetd配置为在端口8443上建立连接时启动我的服务。
因此,Xinetd应该启动我的应用程序,然后让我的应用程序处理更多的传入连接。
我正在重复“警告:无法获取客户端地址:传输端点未连接”,然后Xinetd禁用我的服务10秒钟。
只有当我设置wait = yes时才会发生这种情况。
停止我的应用程序监听端口8443并没有什么区别。
我对xinetd等待标志的理解是正确的还是我对xinetd配置有问题?
我看过手册页,wait = yes通常与UDP相关,但是没有任何内容表示你不能将它与TCP一起使用。
我搜索了SO,我找到的所有内容都使用了tcp和wait = no。
连接到xinetd时出现以下错误。
5786]: warning: can't get client address: Transport endpoint is not connected
5564]: EXIT: MyApplication status=1 pid=5786 duration=0(sec)
5564]: START: MyApplication pid=5787 from=<no address>
5787]: warning: can't get client address: Transport endpoint is not connected
5564]: EXIT: MyApplication status=1 pid=5787 duration=0(sec)
5564]: Deactivating service MyApplication due to excessive incoming connections. Restarting in 10 seconds.
5564]: FAIL: MyApplication connections per second from=<no address>
5564]: Activating service MyApplication
我的配置是:
disable = no
socket_type = stream
protocol = tcp
wait = yes
user = user
server = /usr/bin/MyApplication
port = 8443
type = UNLISTED
flags = IPv4
答案 0 :(得分:0)
以防万一其他人遇到这个问题,我在寻找相同的东西。根据维护者之一Steve Grubb here的评论,他说
等待服务是接受 连接。 telnet不接受连接-它希望连接到 被接受,并将套接字复制到stdin / out描述符。
xinetd也无法检查孩子是否接受了 连接。因此,当您有一个配置为等待的程序时 服务并且它不接受连接,当 xinetd返回选择循环。绕着它走。
子服务器从xinetd fork然后调用exec_server开始启动。当wait=true
时,正如上面提到的,子进程必须接受套接字上的连接。要获取套接字,可以将具有0值的文件描述符与accept一起使用。我在以下使用python,
import socket
s = socket.fromfd(0, socket.AF_INET, socket.SOCK_STREAM)
print(s.accept())
返回(conn,地址),其中conn是可用于在连接上发送和接收数据的新套接字对象。
答案 1 :(得分:-1)
从手册页
wait This attribute determines if the service is single-threaded or multi-threaded and whether or not xinetd accepts the connection or the server program accepts the
connection. If its value is yes, the service is single-threaded; this means that xinetd will start the server and then it will stop handling requests for the
service until the server dies and that the server software will accept the connection. If the attribute value is no, the service is multi-threaded and xinetd
will keep handling new service requests and xinetd will accept the connection. It should be noted that udp/dgram services normally expect the value to be yes
since udp is not connection oriented, while tcp/stream servers normally expect the value to be no.
所以,如果你有wait = yes,你就是单线程。一旦有连接,其他任何东西都无法连接,直到当前会话断开连接或脚本结束。