-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ai_connection.java
More file actions
31 lines (26 loc) · 1.14 KB
/
test_ai_connection.java
File metadata and controls
31 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.io.*;
import java.net.*;
public class test_ai_connection {
public static void main(String[] args) {
System.out.println("Testing AI server connection...");
try {
URL url = new URL("http://localhost:8000/health");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(2000);
conn.setReadTimeout(2000);
int responseCode = conn.getResponseCode();
System.out.println("Response Code: " + responseCode);
if (responseCode == 200) {
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String response = in.readLine();
System.out.println("Response: " + response);
System.out.println("✅ AI server is reachable!");
} else {
System.out.println("❌ Server returned: " + responseCode);
}
} catch (Exception e) {
System.out.println("❌ Connection failed: " + e.getMessage());
}
}
}