Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash during pickup if network is turned off #14

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ class WalletMainActivity : AppCompatActivity() {
if (invitation.isNotEmpty()) {
val app = application as WalletApp
lifecycleScope.launch(Dispatchers.Main) {
val (_, connection) = app.agent.oob.receiveInvitationFromUrl(invitation)
showAlert("Connected to ${connection?.theirLabel ?: "unknown agent"}")
try {
val (_, connection) = app.agent.oob.receiveInvitationFromUrl(invitation)
showAlert("Connected to ${connection?.theirLabel ?: "unknown agent"}")
} catch (e: Exception) {
showAlert("Unable to connect, please check your network connection")
}
}
}
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,25 @@ class MediationRecipient(private val agent: Agent, private val dispatcher: Dispa

if (agent.agentConfig.mediatorPickupStrategy == MediatorPickupStrategy.PickUpV1) {
val message = OutboundMessage(BatchPickupMessage(10), mediatorConnection)
agent.messageSender.send(message)
try {
agent.messageSender.send(message)
} catch (e: Exception) {
// We catch the exception here because if there is a network failure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems too verbose.

// the framework will simply retry picking up the messages later.
logger.debug("Pickup messages failed with the following error: ${e.message}")
}
} else if (agent.agentConfig.mediatorPickupStrategy == MediatorPickupStrategy.Implicit) {
// For implicit pickup, responseRequested must be set to false.
// Since no response is requested, the mediator can respond with queued messages.
// Otherwise, it would respond with a trust ping response.
val message = OutboundMessage(TrustPingMessage("pickup", false), mediatorConnection)
agent.messageSender.send(message, "ws")
try {
// We catch the exception here because if there is a network failure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

// the framework will simply retry picking up the messages later.
agent.messageSender.send(message, "ws")
} catch (e: Exception) {
logger.debug("Pickup messages failed with the following error: ${e.message}")
}
} else {
throw RuntimeException("Unsupported mediator pickup strategy: ${agent.agentConfig.mediatorPickupStrategy}")
}
Expand Down
Loading