Netty で動作するサーバーがあります。クライアントがいくつかのハンドシェイク メッセージを送信し、サーバーが応答します。これらは小さなメッセージであり、問題はありません。
ただし、サーバーがいくつかの大きなメッセージ (各サイズが 131139 バイト) を送信しようとすると、それらが送信されているように見え、 が返され、ChannelFuture
が返されます。ただし、クライアントは完全なメッセージを取得することはなく、最初のメッセージの最初のバイトのみを取得します。4 つか 5 つのメッセージの後、netty は新しいメッセージの送信を停止します。isSuccess()
true
getCause()
null
4097
メッセージを送信する前にチャネルを読んでisWritable()
います (常に が返されますtrue
)。operationComplete
次のメッセージは、 のChannelFutureListener
が起動されたときにのみ試行されます。メッセージがチャネルに書き込まれた後、「INTEREST_CHANGED」イベントが 2 回スローされ、 にisWritable
変更されfalse
、すぐに に変更されたことがログに示されtrue
ます。しかし、メッセージは決してクライアントに届きません。
INFO [New I/O worker #7] (HashSender.java:33) - Attempting send a message: 0
INFO [New I/O worker #7] (HashSender.java:68) - Is channel writable: true
INFO [New I/O worker #7] (FrameLengthPrepender.java:46) - outgoing packet lenght: 131139
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: true
INFO [New I/O worker #7] (HashSender.java:16) - Message Successfully sent. Channel isDone: true, success: true, cancelled: false, error: null
INFO [New I/O worker #7] (HashSender.java:33) - Attempting send a message: 1
INFO [New I/O worker #7] (HashSender.java:68) - Is channel writable: true
INFO [New I/O worker #7] (FrameLengthPrepender.java:46) - outgoing packet lenght: 131139
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: false
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: true
INFO [New I/O worker #7] (HashSender.java:16) - Message Successfully sent. Channel isDone: true, success: true, cancelled: false, error: null
INFO [New I/O worker #7] (HashSender.java:33) - Attempting send a message: 2
INFO [New I/O worker #7] (HashSender.java:68) - Is channel writable: true
INFO [New I/O worker #7] (FrameLengthPrepender.java:46) - outgoing packet lenght: 131139
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: false
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: true
INFO [New I/O worker #7] (HashSender.java:16) - Message Successfully sent. Channel isDone: true, success: true, cancelled: false, error: null
INFO [New I/O worker #7] (HashSender.java:33) - Attempting send a message: 3
INFO [New I/O worker #7] (HashSender.java:68) - Is channel writable: true
INFO [New I/O worker #7] (FrameLengthPrepender.java:46) - outgoing packet lenght: 131139
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: false
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: true
INFO [New I/O worker #7] (HashSender.java:16) - Message Successfully sent. Channel isDone: true, success: true, cancelled: false, error: null
INFO [New I/O worker #7] (HashSender.java:33) - Attempting send a message: 4
INFO [New I/O worker #7] (HashSender.java:68) - Is channel writable: true
INFO [New I/O worker #7] (FrameLengthPrepender.java:46) - outgoing packet lenght: 131139
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: false
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: true
INFO [New I/O worker #7] (HashSender.java:16) - Message Successfully sent. Channel isDone: true, success: true, cancelled: false, error: null
INFO [New I/O worker #7] (HashSender.java:33) - Attempting send a message: 5
INFO [New I/O worker #7] (HashSender.java:68) - Is channel writable: true
INFO [New I/O worker #7] (FrameLengthPrepender.java:46) - outgoing packet lenght: 131139
INFO [New I/O worker #7] (ClientHandler.java:32) - [id: 0xdbb48b90, /192.168.0.3:60105 => /192.168.0.4:25025] INTEREST_CHANGED
INFO [New I/O worker #7] (ClientHandler.java:33) - Is channel writable: false
メッセージが届かない理由を教えてください。
更新: 実際には最初のメッセージの 4097 バイトです。パケット長を示す最初の 4 バイトは数えませんでした。
更新: 送信パケットの長さが 4097 バイト以下の場合、すべてがスムーズに機能します。Netty は、パケットが 4097 バイトを超える場合にのみ中断します。4096 ではなく 4097 です。ベルが鳴りますか?