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

chore(mobile): use sdk to for ping endpoint #13218

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all 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
18 changes: 2 additions & 16 deletions mobile/lib/services/api.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,13 @@ class ApiService implements Authentication {
}

Future<bool> _isEndpointAvailable(String serverUrl) async {
final Client client = Client();

if (!serverUrl.endsWith('/api')) {
serverUrl += '/api';
}

try {
final response = await client
.get(
Uri.parse("$serverUrl/server-info/ping"),
headers: getRequestHeaders(),
)
.timeout(const Duration(seconds: 5));

_log.info("Pinging server with response code ${response.statusCode}");
if (response.statusCode != 200) {
_log.severe(
"Server Gateway Error: ${response.body} - Cannot communicate to the server",
);
return false;
}
await setEndpoint(serverUrl);
await serverInfoApi.pingServer().timeout(Duration(seconds: 5));
} on TimeoutException catch (_) {
return false;
} on SocketException catch (_) {
Expand Down
Loading