Using netty communication will merge two short-spaced data frames into one data frame?

for example, I use netty to write to the server, use simple Socket to simulate the client, and send data to the server like this:

bos.write(data);
bos.flush();

in this way, there is a problem. When the time interval between sending data from the client is very short, the msg obtained by the channelRead (ChannelHandlerContext ctx, Object msg) method of netty may contain the data from the client twice at the same time, so the server will have problems when parsing the data. Want to know why the problem of merging data frames occurs and how to solve it?

Feb.28,2021

channel is inherently non-blocking, so the data obtained is not completely real-time, and there may be delay, so it is normal for the data server to send twice and receive once.

the point is that you should not separate the data by "frames". Instead, you should agree on your own segmentation method. For example, each data is accompanied by a length, or a number of special bytes as delimiters, and so on.


netty adhesive package

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b614-2b2db.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b614-2b2db.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?