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

发布于 2024-09-05 11:17:23 字数 1280 浏览 8 评论 0原文

我正在嵌入式 Linux 环境中工作。

它在启动时启动一个 telnet 守护进程,该守护进程监视特定端口并在收到连接时启动程序。

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

PROGA - 将以不规则的间隔输出一些数据。当它不输出数据时,每隔 X 时间段它会发送一个 'heartbeat' 类型的字符串,让客户端知道我们仍然处于活动状态,即“heartbeat\r\n”

在随机的时间后,客户端(使用Linux 版本的 telnet,启动方式为: telnet xxx.xxx.xxx.xxx 1234) 将无法接收“heartbeat\r\n”

客户端看到的数据:

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

heartbeat 已发送:

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

检查结果,它始终是heartbeat的长度。记录到 syslog 向我们显示 printf() 正在以适当的时间间隔成功执行,

此后我已添加到 tcdrainfflush 其中两者都返回成功,但似乎对情况没有帮助。

任何帮助将不胜感激。

**UDPATE:从服务器端获取了wireshark捕获。很明显,心跳正在连续发送。没有打嗝,没有延误。不过在客户端发现了一些有趣的东西。此测试用例中的客户端(Ubuntu 9.04 上的 telnet)似乎突然停止接收心跳(如上所述)。 Wireshark 证实了这一点,数据包出现大幅暂停。好吧,一旦客户端停止接收心跳,按下任何按键(在客户端上)似乎都会触发客户端缓冲区中的大量数据(所有心跳)。客户端上的 Wireshark 也将如此大量的数据全部显示在一个数据包中。

不幸的是我真的不知道这意味着什么。这是线路模式开/关吗?行结尾 (\r\n) 非常清晰。

**更新 2:运行 netcat 而不是 telnetd,问题无法重现。

I'm Working in an embedded linux environment.

it launches a telnet daemon on startup which watches on a particular port and launches a program when a connection is received.

i.e.

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

PROGA - will output some data at irregular intervals. 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 i.e. "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'

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. Logging to syslog shows us that the printf() is executing with success at the proper intervals

I've since added in a tcdrain and fflush which both return success, but do not seem to help the situation.

Any help would be appreciated.

**UDPATE: got a wireshark capture from the server side. Very Clearly the heartbeat is being sent continuously. No Hicups, no delays. 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). Wireshark confirms this, big pause in packets. 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.

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.

**Update 2: running netcat instead of telnetd, the problem is not reproducible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似狗非友 2024-09-12 11:17:25

我要做的第一件事就是退出 Wireshark 并尝试查明服务器是否真正发送消息。在服务器和第三方 PC 上运行 Wireshark 会很有帮助。上次心跳有什么不同吗?


编辑。嗯,这是您客户的一个有趣发现。

似乎有某种终端的东西挡住了。您可能想使用 netcat 程序而不是 telnetd。 netcat 设计用于以原始模式通过 TCP 会话发送任意数据,无需任何特殊格式,并且它能够将任意进程连接到套接字。在 Windows 计算机上,您可以在原始模式下使用 PuTTY 来完成相同的操作。

与第三方一起检查客户端和服务器之间的流量可能仍然值得。内核可能正在优化对网络的写入并在内部缓冲数据。这是确保所看到的就是线路上真实发生的情况的唯一方法。

The first thing I would do is get out Wireshark and try to find out if the server is truly sending the message. It would be instructive to run Wireshark at the server as well as third party PC. 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 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. On a Windows machine you can use PuTTY in raw mode to accomplish the same thing.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文