Occasionally, but not rarely, the findMatchForRequest:withCompletionHandler:
returns with error 13 or GKErrorMatchRequestInvalid
:
"The requested operation could not be completed because the match request is invalid."
The documentation only says:
GKErrorMatchRequestInvalid
The match request’s properties are impossible to fulfill. For example, the minimum number of players cannot be larger than the maximum number of players. Available in iOS 4.0 and later.
I think that GKErrorMatchRequestInvalid
never occurs on 1st try, that is, when directly after launching from Xcode, but only on 2nd/3rd/... tries. Happens on either the device or the simulator. So I assume that I am doing something wrong, but what? Is there an exhaustive list of conditions under which GKMatchRequest
is invalid?
Tried to recover from GKErrorMatchRequestInvalid
by recalling findMatchForRequest:
, but never succeed: once I get an 'invalid' match
, then all further findMatchForRequest:
calls also return with an 'invalid' match
. Trying to remedy this by using both [[GKMatchmaker sharedMatchmaker] cancel]
and [[GKMatchmaker sharedMatchmaker] finishMatchmakingForMatch:
... obviously, I don't even have a valid match
to finishMatchmakingFor:
.
The matchmaking happens in a singleton (if that matters). Here's the relevant code:
GKMatchRequest *request = [GKMatchRequest new];
request.minPlayers = 3;
request.maxPlayers = 4;
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error)
{
if (error)
{
if (error.code == 503 ||
error.code == GKErrorMatchRequestInvalid ||
error.code == GKErrorNotAuthenticated ||
error.code == GKErrorCommunicationsFailure ||
error.code == GKErrorUnknown ||
error.code == GKErrorInvalidPlayer ||
error.code == GKErrorInvalidParameter ||
error.code == GKErrorAuthenticationInProgress)
{
[self.delegate restartMatchmaking];
}
}
else if (match)
{
// happy-path
}
}];
I get the same exact thing. And ran the same tests. This seems to be really, "Request can not be submitted" and Not related to REQUEST contents are invalid/incorrect.
Suspected reasons:
An authentication issue (maybe did not re-authenticate)
Maybe MatchMaker thinks a request (last request) is still active. (was GameCenter restarted while waiting for a match?) I could not find a way to query matchmaker to see if a request is active.
MayBe MatchMaker CANCEL is hitting some timing hole and not being accepted/Completed.
Maybe a hosed up state, where the request can not be submitted to (or accepted by) MatchMaker (most likely)