Game Center multiplayer over 3G/WWAN - getLocalConnectionData timed out

902 views Asked by At

I have a multiplayer game that uses GameCenter for networking. Network games over wifi using GKMatch work perfectly, but over 3G they never connect. My

-[GKMatchmaker findMatchForRequest:
withCompletionHandler:]

completion handler block is invoked with an error code 503, which isn't a GKErrorDomainCode according to that header. Instead it appears to be an HTTP error code.

Here's my code:

//GKLocalPlayer is already authenticated at this point
    _matchRequest = [[[GKMatchRequest alloc] init] autorelease];
    [_matchRequest setMinPlayers: 2];
    [_matchRequest setMaxPlayers: 2];
    GKMatchmaker *matchmaker = [GKMatchmaker sharedMatchmaker];
    [matchmaker findMatchForRequest: _matchRequest
              withCompletionHandler:
     ^(GKMatch *match, NSError *error) {
         if (error)
         {
             if ([error code] != GKErrorCancelled)
             {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     [[[[UIAlertView alloc] initWithTitle: 
                          NSLocalizedString(@"Can't find match.", @"Alert title for when automatching failed") 
                          message: [error localizedDescription] 
                          delegate: nil 
                          cancelButtonTitle: NSLocalizedString(@"OK", @"Button text for OK button") 
                          otherButtonTitles: nil] autorelease] show];
                 });
             }
             else
             {
                    NSLog(@"Canceled :(");
             }
         }
         else
         { 
             dispatch_async(dispatch_get_main_queue(), ^{
                 // do some main-thread stuff specific to my app
                 _match = [match retain];
                 [_match setDelegate: self];
             });
         }
     } ];
}

SNJGKLocalPlayerManager just logs the player into GameCenter. Typical output from this would be a UIAlertView saying "The operation could not be completed. getLocalConnectionData timed out" from the line in the first dispatch_async block. If I use NSLog to output the error code, it's 503.

If you've gotten GameCenter multiplayer to work over 3G and don't want to pore over my code, feel free to share your working code and I'll try to find where mine goes wrong! Thanks!

0

There are 0 answers