Skip to content

Commit d74e1b1

Browse files
authored
Merge pull request #781 from ZacharyZcR/feat/guacd-status-check
feat: check guacd availability before RDP/VNC connection
2 parents 629961f + a1a4422 commit d74e1b1

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/ui/features/guacamole/GuacamoleApp.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect, useCallback } from "react";
22
import { GuacamoleDisplay } from "@/features/guacamole/GuacamoleDisplay.tsx";
33
import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx";
4-
import { getGuacamoleTokenFromHost } from "@/main-axios.ts";
4+
import { getGuacamoleTokenFromHost, getGuacdStatus } from "@/main-axios.ts";
55
import { useTranslation } from "react-i18next";
66
import { AlertCircle, RefreshCw } from "lucide-react";
77
import { Button } from "@/components/button.tsx";
@@ -75,8 +75,19 @@ const GuacamoleAppInner: React.FC<GuacamoleAppInnerProps> = ({
7575
useEffect(() => {
7676
setToken(null);
7777
setError(null);
78-
getGuacamoleTokenFromHost(hostId)
79-
.then((result) => setToken(result.token))
78+
getGuacdStatus()
79+
.then((status) => {
80+
if (status.guacd.status !== "connected") {
81+
setError(
82+
"Remote desktop service (guacd) is not available. Please ensure guacd is running and accessible.",
83+
);
84+
return;
85+
}
86+
return getGuacamoleTokenFromHost(hostId);
87+
})
88+
.then((result) => {
89+
if (result) setToken(result.token);
90+
})
8091
.catch((err) => setError(err?.message || t("guacamole.failedToConnect")));
8192
}, [hostId, retryCount]);
8293

src/ui/main-axios.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4501,6 +4501,13 @@ export async function getGuacamoleTokenFromHost(
45014501
}
45024502
}
45034503

4504+
export async function getGuacdStatus(): Promise<{
4505+
guacd: { status: string };
4506+
}> {
4507+
const response = await authApi.get("/guacamole/status");
4508+
return response.data;
4509+
}
4510+
45044511
// ============================================================================
45054512
// RBAC MANAGEMENT
45064513
// ============================================================================

0 commit comments

Comments
 (0)