purplecabbage/phonegap-plugins — Issue #50: GAPSocket: Should not read on connect
Author: dieppe
Created: 2011-12-20 22:33:44+00:00
State: open

I had a weird bug where I would always get a (null) error message after sending data and reading the response. It turns out that commenting the following line of code:
[sock readDataToData:[AsyncSocket CRLFData] withTimeout:-1 tag:0]; (l.195)
in GAPSocketCommand.m solved the problem.
The thing is that it reads on connect, and the server I connect to don't send anything, it only returns data when I send something.

Note that this is not a proper fix (but it's enough for me), since you won't receive any data unless you send some.
I think the way to go should be to have a flag set to true in the didReadData delegate method, and only if this flag is set to true call the readDataToData method in the send method of GAPSocketCommand.m.

I don't have time to do that right now, and won't have time until a while. Just thought I'd at least share this issue and a way to maybe fix it.