GCDAsyncSocket - large amount of data #282

Open
mbutan opened this Issue Dec 15, 2013 · 3 comments

Projects

None yet

2 participants

@mbutan
mbutan commented Dec 15, 2013

Hi,

I have really strange problem with SSL async connection. Everything works perfectly when reading data is small and could be received in one package. For this operation I use these methods:
[_asyncSocket writeData:data withTimeout:-1 tag:0];
[sock readDataToData:[GCDAsyncSocket LFData] withTimeout:-1 tag:0];

However when coming data has to be split on some parts ("didReadPartialDataOfLength" is invoked). Method didReadData is never called by first time, I have to invoke once again same request then in results I receive twice same response in didReadData. It's really wierd problem. Anybody have any idea what's wrong.

Sometimes happen that I writeData with some tag (for example 1) and in didReadData I receive tag that I used before that request (for example 0).
Only after the second call the same method receives a valid tag.

Everything happens only for bigger parts of data.

@adozenlines

You might have a thread issue. Are you using GCDAsyncSocket on the same thread as the calling thread ?
On Dec 15, 2013, at 5:34 PM, mbutan notifications@github.com wrote:

Hi,

I have really strange problem with SSL async connection. Everything works perfectly when reading data is small and could be received in one package. For this operation I use these methods:
[_asyncSocket writeData:data withTimeout:-1 tag:0];
[sock readDataToData:[GCDAsyncSocket LFData] withTimeout:-1 tag:0];

However when coming data has to be split on some parts ("didReadPartialDataOfLength" is invoked). Method didReadData is never called by first time, I have to invoke once again same request then in results I receive twice same response in didReadData. It's really wierd problem. Anybody have any idea what's wrong.

Sometimes happen that I writeData with some tag (for example 1) and in didReadData I receive tag that I used before that request (for example 0).
Only after the second call the same method receives a valid tag.

Everything happens only for bigger parts of data.


Reply to this email directly or view it on GitHub.

@mbutan
mbutan commented Dec 16, 2013

I will check this once again, but I use same dispatch_queue for all operations. Ofc same for initialization socket and calling write methods

@mbutan
mbutan commented Dec 16, 2013

Yes, all of methods are calling from same async queue (ofc I can not ensure that it's working on the same thread, but only on same queue).

For huge amount of data after invoke "writeData", 2-3 times calling is "didReadPartialDataOfLength" and all of events are stopped. Than I have to send once again write method, to receive twice "readData" with full response.

It happens also on main thread queue but only for huge amount of data when "didReadPartialDataOfLength" is invoked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment