mpush-client-oc icon indicating copy to clipboard operation
mpush-client-oc copied to clipboard

当数据量大的时候会出现异常现象,主要是获取body的length

Open FrankCYQ opened this issue 7 years ago • 9 comments

NSData *lengthData = [MessageDataPacketTool getsubdata:data withRange:NSMakeRange(0, 4)];

int length = 0;

[lengthData getBytes: &length length: sizeof(uint32_t)];
NTOHL(length);

IP_PACKET ipPacket;
ipPacket.length = length;

image

很明显这个length应该是错误的,也不清楚是什么原因

FrankCYQ avatar Dec 15 '17 10:12 FrankCYQ

I also have met the same problem,any solution?

FrankSwift avatar Dec 25 '17 08:12 FrankSwift

数据量有多大呢? 超出了服务端设置的4个字节的最大长度吗

Fight0913 avatar Jan 22 '18 07:01 Fight0913

比如利用压测工具每秒500的并发量就有问题,初步判断是socket粘包,目前demo的逻辑应该是有问题的,心跳数据也会同message数据合在一起的

On 22 Jan 2018, at 3:35 PM, Fight0913 [email protected] wrote:

数据量有多大呢? 超出了服务端设置的4个字节的最大长度吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mpusher/mpush-client-oc/issues/8#issuecomment-359345834, or mute the thread https://github.com/notifications/unsubscribe-auth/AE3Vnr3UHYIam6y0w5Yzebi3SVffbvU8ks5tNDpYgaJpZM4RDSaD.

FrankCYQ avatar Jan 29 '18 05:01 FrankCYQ

粘包问题已经处理过的,我用数据量较大的消息测过的,你这个问题应该不是这个问题,心跳数据也会同message数据合在一起的只是和你所了解的方式不同罢了

原始邮件 发件人:[email protected] 收件人:mpusher/[email protected] 抄送:[email protected]; [email protected] 发送时间:2018年1月29日(周一) 13:57 主题:Re: [mpusher/mpush-client-oc] 当数据量大的时候会出现异常现象,主要是获取body的length (#8)

比如利用压测工具每秒500的并发量就有问题,初步判断是socket粘包,目前demo的逻辑应该是有问题的,心跳数据也会同message数据合在一起的

On 22 Jan 2018, at 3:35 PM, Fight0913 [email protected] wrote:

数据量有多大呢? 超出了服务端设置的4个字节的最大长度吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub ,">https://github.com/mpusher/mpush-client-oc/issues/8#issuecomment-359345834, or mute the thread .">https://github.com/notifications/unsubscribe-auth/AE3Vnr3UHYIam6y0w5Yzebi3SVffbvU8ks5tNDpYgaJpZM4RDSaD.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Fight0913 avatar Feb 02 '18 06:02 Fight0913

最新的Demo也是会出现这个问题的,在socket接收方法里面定位到data偶然会出现data.length == 2的情况(data.length == 1代表心跳),另外一个问题是大量数据压测,可能会出现doule free的情况,但是如果将接受到的数据处理过程全部放在主线程中,就可以避免。

GoKnow avatar Apr 24 '18 11:04 GoKnow

data.length == 2的数据能解析出来吗? 可以看下协议头里的length的数值多少,两个比较一下,就知道是半包 还是 粘包问题了

原始邮件 发件人:[email protected] 收件人:mpusher/[email protected] 抄送:[email protected]; [email protected] 发送时间:2018年4月24日(周二) 19:26 主题:Re: [mpusher/mpush-client-oc] 当数据量大的时候会出现异常现象,主要是获取body的length (#8)

最新的Demo也是会出现这个问题的,在socket接收方法里面定位到data偶然会出现data.length == 2的情况(data.length == 1代表心跳),另外一个问题是大量数据压测,可能会出现doule free的情况,但是如果将接受到的数据处理过程全部放在主线程中,就可以避免。 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Fight0913 avatar Apr 25 '18 09:04 Fight0913

数据解析不来,就是突然会出现data长度为2,这个时候直接导致崩溃,只能对这个进行特殊处理,把data.length==2的直接过滤,把他也当成心跳包这样子的无用数据。

GoKnow avatar Apr 27 '18 09:04 GoKnow

你给我这些信息,我怎么能帮你解决问题呢,要么加我QQ我连你们的服务,调试一下,要么你给我更具体的信息

原始邮件 发件人:[email protected] 收件人:mpusher/[email protected] 抄送:[email protected]; [email protected] 发送时间:2018年4月27日(周五) 17:10 主题:Re: [mpusher/mpush-client-oc] 当数据量大的时候会出现异常现象,主要是获取body的length (#8)

数据解析不来,就是突然会出现data长度为2,这个时候直接导致崩溃,只能对这个进行特殊处理,把data.length==2的直接过滤,把他也当成心跳包这样子的无用数据。 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Fight0913 avatar Apr 27 '18 09:04 Fight0913

image

FrankSwift avatar Jun 04 '18 10:06 FrankSwift