lukeredpath/libPusher — Issue #8: 3G support
Author: papin
Created: 2011-10-31 15:27:09+00:00
State: open

Hi,
I have strange issue with 3G.
In wifi, the libpusher works without problem but in 3G I receive the following error :

2011-10-31 16:20:15.561 transcovo[308:707] [pusher-(null)] Failed to connect to pusher, error: Error Domain=ZTWebSocketErrorDomain Code=2 "The operation couldn’t be completed. (ZTWebSocketErrorDomain error 2.)"
2011-10-31 16:20:15.563 transcovo[308:707] [pusher-(null)] Reconnecting after 5 seconds...
2011-10-31 16:20:20.647 transcovo[308:707] *** Terminating app due to uncaught exception 'AsyncSocketException', reason: 'Attempting to connect while connected or accepting connections. Disconnect first.'
*** Call stack at first throw:
(
0 CoreFoundation 0x3144e64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x34f69c5d objc_exception_throw + 24
2 CoreFoundation 0x3144e491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x3144e4cb +[NSException raise:format:] + 34
4 transcovo 0x0001b45d -[AsyncSocket connectToHost:onPort:withTimeout:error:] + 172
5 transcovo 0x00039a4d -[ZTWebSocket open] + 220
6 transcovo 0x000164ad -[PTPusherConnection connect] + 72
7 transcovo 0x00013c0d __-[PTPusher reconnectAfterDelay]_block_invoke_1 + 52
8 libdispatch.dylib 0x35d348e7 _dispatch_call_block_and_release + 10
9 libdispatch.dylib 0x35d30771 _dispatch_after_timer_callback + 12
10 libdispatch.dylib 0x35d32341 _dispatch_source_invoke + 436
11 libdispatch.dylib 0x35d30041 _dispatch_queue_invoke + 92
12 libdispatch.dylib 0x35d301c3 _dispatch_main_queue_callback_4CF$VARIANT$up + 262
13 CoreFoundation 0x3142893b __CFRunLoopRun + 1334
14 CoreFoundation 0x313b8ec3 CFRunLoopRunSpecific + 230
15 CoreFoundation 0x313b8dcb CFRunLoopRunInMode + 58
16 GraphicsServices 0x30d3741f GSEventRunModal + 114
17 GraphicsServices 0x30d374cb GSEventRun + 62
18 UIKit 0x314ded69 -[UIApplication _run] + 404
19 UIKit 0x314dc807 UIApplicationMain + 670
20 transcovo 0x00003eb3 main + 82
21 transcovo 0x00003e5c start + 40
)
terminate called after throwing an instance of 'NSException'

The xcode debugger show me the following method in class "AsyncSocket.m" :

- (BOOL)connectToHost:(NSString *)hostname
onPort:(UInt16)port
withTimeout:(NSTimeInterval)timeout
error:(NSError **)errPtr
{
if(theDelegate == NULL)
{
[NSException raise:AsyncSocketException
format:@"Attempting to connect without a delegate. Set a delegate first."];
}

if(theSocket4 != NULL || theSocket6 != NULL)
{
//CRASH HERE

[NSException raise:AsyncSocketException
format:@"Attempting to connect while connected or accepting connections. Disconnect first."];
}

if(![self createStreamsToHost:hostname onPort:port error:errPtr]) goto Failed;
if(![self attachStreamsToRunLoop:nil error:errPtr]) goto Failed;
if(![self configureStreamsAndReturnError:errPtr]) goto Failed;
if(![self openStreamsAndReturnError:errPtr]) goto Failed;

[self startConnectTimeout:timeout];
theFlags |= kDidPassConnectMethod;

return YES;

Failed:
[self close];
return NO;
}

Do you have an idea why I have this issue ?

I also show, there were an issue like this and it was fix with the SSL. How can I set to use SSL instead ?