无法发送TCP响应的可能原因?

2024-06-12 00:26:40 发布

您现在位置:Python中文网/ 问答频道 /正文

即使连接处于活动状态,也无法发送TCP响应的任何原因(i、 e我们能够在同一时间通过同一连接接收TCP流)

TCP连接是使用Twisted(Python)设置的

总结你的系统

  • 我们的应用程序(假设B)通过TCP连接到应用程序a

  • B也通过IPC(I)通过0MQ连接到C(独立服务 相信它是Unix套接字)

  • C通过TCP(通过SSL)连接到PostgresSQL

正常的消息流如下所示

A --TCP--> B -- IPC(0MQ) --> C (C query DML over TCP to Postgres)
                               |
                               |
A <--TCP-- B <-- IPC(0MQ) <-- C (DML Result)

现在,有一段时间(随机发生)对TCP服务器的响应(即从B到A)没有被发送

我们使用以下ngrep(其中x.x.x.x是IP或TCP服务器)来确认上述内容

ngrep -d eno1 -pqtW byline net x.x.x.x

但是我们的日志中有一个条目说,发送给A的响应(来自B)(在我们通过TCP写入响应之后写入)

def send_tcp_response_to_sms800(self,response):
    self.log.info("Sending TCP response for message id {message_id}",message_id=response[0])
    message = self.create_message(response)
    ber_enc_message = ber_encoder.encode(message)
    self.transport.write(b'\x7e\x7e\x7e\x7e')
    self.transport.write(struct.pack('>I', len(ber_enc_message)))
    self.transport.write(ber_enc_message)  ## <-- response written to TCP
    self.log.info("response sent to sms800 from {qs}",qs=self.queue_server_name)
    timestamp = strftime("%a, %d %b %Y %H:%M:%S")
    self.log_message_id_in_response(response[0],timestamp) ## <-- ## log file where message id from the response is logged

为了安全起见,这和记忆无关

ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 30933
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

我不知道这可能是什么原因

注:我们已经彻底检查过了,这里B到C之间的通信不是问题。我们交叉检查了B和C应用程序的日志,发现B和C之间有一对匹配的请求/响应。


Tags: toselflogid应用程序messagesizeresponse