robbiehanson / CocoaAsyncSocket

Asynchronous socket networking library for Mac and iOS
Other
12.46k stars 3k forks source link

GCDAsyncUdpSocket Freezes #169

Closed srz2 closed 10 years ago

srz2 commented 11 years ago

Regardless of letting the socket call once or continuously, during a stable connection, it eventually stops receiving data. This is a big problem. I have tried everything from closing the connection to reopening but everything seems to lead to it freezing. Even running through Instruments, it shows the UDP connection terminates.

One thing that might make this a special case is the fact that this is a multicast UDP. Please look into this! I need some sort of help!

icanswiftabit commented 10 years ago

Same thing here... are you going to do something with this?

dvor commented 10 years ago

@srz2 @Dudi00 can you get some logs and post them here? You can enable it by changing #if 0 to #if 1 in GCDAsyncUDPSocket.m file on line 32.

icanswiftabit commented 10 years ago

@dvor at line 120 in DDLog.m in NSLogDebug "Called object type 'NSString *' is not a function or function pointer".

I comment line 120, 144 and 567. Then I change line 32 in GCDAsyncUDPSocket from #if 0 to #if 1 but there is no output in console.

UPDATE

ok I "fix it" with little change in macro #define NSLogDebug(frmt, ...) do{ if(DD_DEBUG) NSLog((frmt), ##__VA_ARGS__); } while(0) to #define NSLogDebug(frmt, ...) do{ if(DD_DEBUG) NSLog(frmt, ##__VA_ARGS__); } while(0) I have output, but be prepare for long output. I test for two diffrent buffer size 1486 and 47.

iOS 7 buffer 1486 https://gist.github.com/Dudi00/8096469

iOS 6 buffer 1486 https://gist.github.com/Dudi00/8096493

iOS 7 buffer 47 https://gist.github.com/Dudi00/8096505

iOS 6 buffer 47 https://gist.github.com/Dudi00/8096554

if tl;dr problem occurs only under iOS 6 buffer 1486. You can see it in line 125/126 173/174 221/222 381/382 421/422 445/446 473/474 etc. Hope that helps.

dvor commented 10 years ago

Thanks a lot @Dudi00! I'll check those logs ASAP.

dvor commented 10 years ago

@Dudi00 As I understand originally the problem was with socket that eventually wasn't receiving data at all. In your logs socket continues receiving data and everything seems to be okay.

I believe that lag in logs is because of intensive data rate. GCDAsyncUdpSocket starts receiving data right after socket's callback and I don't think that anything can be done for removing the lag.

icanswiftabit commented 10 years ago

Thanks @dvor I suspected such a scenario. So recepie for that problem is lower Your buffer @srz2 :)

dvor commented 10 years ago

Closing this issue for now.