forked from nvmax/FluxComfyDiscordbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection_test.py
65 lines (54 loc) · 2.08 KB
/
connection_test.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import requests
import os
from dotenv import load_dotenv
import websocket
import time
def test_comfyui_connection(server):
print(f"\nTesting ComfyUI connection to {server}:8188...")
try:
response = requests.get(f"http://{server}:8188/")
print("✓ ComfyUI API is accessible")
# Test WebSocket connection
ws_url = f"ws://{server}:8188/ws"
ws = websocket.create_connection(ws_url, timeout=10)
ws.close()
print("✓ ComfyUI WebSocket is accessible")
return True
except Exception as e:
print(f"✗ Failed to connect to ComfyUI: {str(e)}")
return False
def test_bot_webserver(server):
print(f"\nTesting Bot Web Server connection to {server}:8080...")
try:
# Send a test request
response = requests.post(
f"http://{server}:8080/update_progress",
json={"test": "connection"},
timeout=5
)
print("✓ Bot Web Server is accessible")
return True
except Exception as e:
print(f"✗ Failed to connect to Bot Web Server: {str(e)}")
return False
def main():
load_dotenv()
bot_server = os.getenv('BOT_SERVER', 'localhost')
comfy_server = os.getenv('server_address', 'localhost')
print("Connection Test Utility")
print("======================")
comfy_ok = test_comfyui_connection(comfy_server)
bot_ok = test_bot_webserver(bot_server)
print("\nSummary")
print("=======")
print(f"ComfyUI Connection: {'✓ OK' if comfy_ok else '✗ Failed'}")
print(f"Bot Web Server: {'✓ OK' if bot_ok else '✗ Failed'}")
if not (comfy_ok and bot_ok):
print("\nTroubleshooting Tips:")
print("1. Check if the server addresses in .env are correct")
print("2. Ensure both servers are running")
print("3. Check if firewalls are allowing connections")
print("4. Verify the ports (8188 for ComfyUI, 8080 for Bot) are not in use")
print("5. Try running both servers with administrator privileges")
if __name__ == "__main__":
main()