简体   繁体   English

telnet客户端连接停止接收数据,服务器仍在发送

[英]telnet client connection stops receiveing data, server is still sending

I'm Working in an embedded linux environment. 我在嵌入式Linux环境中工作。

it launches a telnet daemon on startup which watches on a particular port and launches a program when a connection is received. 它在启动时启动一个telnet守护程序,它监视特定端口并在收到连接时启动程序。

ie

telnetd -l /usr/local/bin/PROGA -p 1234

PROGA - will output some data at irregular intervals. PROGA - 将以不规则的间隔输出一些数据。 When it is not outputting data, every X period of time it sends out a 'heartbeat' type string to let the client know that we are still active ie "heartbeat\\r\\n" 当它没有输出数据时,每隔X段发出一个“心跳”类型字符串,让客户知道我们仍处于活动状态,即“heartbeat \\ r \\ n”

After a random amount of time, the client (use a linux version of telnet, launched by: telnet xxx.xxx.xxx.xxx 1234) will fail to receive the 'heartbeat\\r\\n' 经过一段随机的时间后,客户端(使用linux版本的telnet,由telnet xxx.xxx.xxx.xxx 1234)将无法收到'heartbeat \\ r \\ n'

The data the client sees: 客户看到的数据:

heartbeat  
heartbeat  
heartbeat  
...
heartbeat
[nothing, should have received heartbeat]
[nothing forever]

heartbeat is sent: 心跳发送:

result = printf("%s", heartbeat);

checking result, it is always the length of heartbeat . 检查结果,总是heartbeat的长度。 Logging to syslog shows us that the printf() is executing with success at the proper intervals 记录到syslog会向我们显示printf()以适当的间隔成功执行

I've since added in a tcdrain and fflush which both return success, but do not seem to help the situation. 我已经添加了一个tcdrainfflush ,它们都取得了成功,但似乎并没有帮助这种情况。

Any help would be appreciated. 任何帮助,将不胜感激。

**UDPATE: got a wireshark capture from the server side. ** UDPATE:从服务器端获取了wireshark捕获。 Very Clearly the heartbeat is being sent continuously. 很明显,心跳正在不断发送。 No Hicups, no delays. 没有Hicups,没有延迟。 Found something interesting on the client though. 但是在客户端发现了一些有趣的东西 The client in this test case (telnet on Ubuntu 9.04) seems to suddenly stop receiving heartbeat (as describes above). 这个测试用例中的客户端(Ubuntu 9.04上的telnet)似乎突然停止接收心跳(如上所述)。 Wireshark confirms this, big pause in packets. Wireshark证实了这一点,数据包大幅停顿。 Well, once the client had stopped receiving the heartbeat, pressing any keystroke (on the client) seems to trigger a spew of data from the client's buffer (all heartbeats). 好吧,一旦客户端停止接收心跳,按下任何击键(在客户端上)似乎会触发来自客户端缓冲区(所有心跳)的数据。 Wireshark on the client also shows this massive amount of data all in one packet. 客户端上的Wireshark还在一个数据包中显示大量数据。

Unfortunately I don't really know what this means. 不幸的是,我真的不知道这意味着什么。 It this a line mode on/off thing? 这是一个线路模式开/关的东西? Line endings (\\r\\n) are very clearly coming through. 线路结尾(\\ r \\ n)非常明显地通过。

**Update 2: running netcat instead of telnetd, the problem is not reproducible. **更新2:运行netcat而不是telnetd,问题不可重现。

The first thing I would do is get out Wireshark and try to find out if the server is truly sending the message. 我要做的第一件事是找出Wireshark并试图找出服务器是否真正发送消息。 It would be instructive to run Wireshark at the server as well as third party PC. 在服务器和第三方PC上运行Wireshark是有益的。 Is there anything different about the last heartbeat? 最后一次心跳有什么不同吗?


Edit. 编辑。 Well, that was an interesting find on your client. 嗯,这对您的客户来说是一个有趣的发现。

It seems like there's some sort of terminal thing in the way. 似乎在路上有某种终端的东西。 You may want to use the netcat program rather than telnetd. 您可能希望使用netcat程序而不是telnetd。 netcat is designed for sending arbitrary data over a TCP session in raw mode, without any special formatting, and it has the ability to hook up an arbitrary process to a socket. netcat用于在原始模式下通过TCP会话发送任意数据,没有任何特殊格式,并且它能够将任意进程连接到套接字。 On a Windows machine you can use PuTTY in raw mode to accomplish the same thing. 在Windows机器上,您可以在原始模式下使用PuTTY来完成同样的事情。

It may still be worth examining traffic with a third party between your client and server. 在客户端和服务器之间与第三方检查流量可能仍然值得。 The kernel may be optimizing away writes to the network and internally buffering data. 内核可能正在优化远程写入网络和内部缓冲数据。 That's the only way to ensure that what see is what's really happening on the wire. 这是唯一可以确保看到线路上真正发生的事情的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM