---
title: "session(_:connectionWithPeerFailed:withError:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gksessiondelegate/session(_:connectionwithpeerfailed:witherror:)"
---

# session(_:connectionWithPeerFailed:withError:)

Received by the delegate when an attempt to connect to another peer failed.

## Declaration

```swift
optional func session(_ session: GKSession, connectionWithPeerFailed peerID: String, withError error: any Error)
```

## Parameters

- `session`: The session that received the message.
- `peerID`: A string that uniquely identifies the peer.
- `error`: The error that occurred.

## Discussion

Discussion The error parameter can be used to inform the user of why the connection failed. important: If a GKPeerPickerController object is being used to configure the session, the controller handles this message automatically. Your delegate can ignore it if the peer picker dialog is in use.

## See Also

### Connection Errors

- [session(_:didFailWithError:)](gamekit/gksessiondelegate/session(_:didfailwitherror:).md)
