개발환경 네트워크 문제 개선

This commit is contained in:
2026-02-03 10:18:38 +09:00
parent ccd25bb491
commit 3e874fb863
8 changed files with 1214 additions and 0 deletions

View File

@@ -0,0 +1,160 @@
# Quick Fix Guide for "Failed to Connect to Server"
## Your Issue: Teammate sees "CONNECTED" but can't join
This is likely a **Firewall** issue even with port forwarding.
## Immediate Actions (Try in Order)
### 1. Disable Windows Firewall Temporarily (Test Only)
```
Windows Security → Firewall & network protection → Private network → Microsoft Defender Firewall: OFF
Public network → Microsoft Defender Firewall: OFF
```
Then test connection. If it works, re-enable and create specific rule for Unity.
### 2. Add Unity Exclusion to Firewall
Run these commands as Administrator in PowerShell/CMD:
```
# Allow Unity Editor
netsh advfirewall firewall add rule name="Unity Editor" dir=in action=allow program="%ProgramFiles%\Unity\Hub\Editor\*\Unity.exe" enable=yes
# Allow your built executable (replace path)
netsh advfirewall firewall add rule name="Northbound Game" dir=in action=allow program="D:\Northbound\Build\Northbound.exe" enable=yes profile=any
# Allow port 7777
netsh advfirewall firewall add rule name="Unity Port 7777" dir=in action=allow protocol=TCP localport=7777 enable=yes profile=any
```
### 3. Verify Port Forwarding is Working
Go to: https://www.yougetsignal.com/tools/open-ports/
- Enter your PUBLIC IP (what you give to teammate)
- Enter port 7777
- Click "Check Port"
**Expected:** "Port 7777 is open on [YOUR PUBLIC IP]"
**If closed:** Port forwarding is incorrect
### 4. Add Debug Scripts to Scene
Add these components to your NetworkManager GameObject:
1. **ConnectionDiagnostics** - Checks for configuration issues
2. **NetworkDebugger** - Shows detailed connection logs
3. **NetworkConnectionFixer** - Fixes common timeout issues
Right-click each and select "Run Diagnostics" or "Fix All Known Issues"
## What to Check in Console
### Host Should See:
```
✓ [NetworkConnectionFixer] Network fixes applied
✓ [ConnectionDiagnostics] System Healthy
✓ [NetworkDebugger] Server Started Successfully
✓ [NetworkDebugger] Listening on: 0.0.0.0:7777
✓ [NetworkDebugger] Client Connected: [ID]
✓ [ConnectionHandler] 클라이언트 [ID] 승인됨. 수동 스폰으로 대기.
```
### Client Should See:
```
✓ [NetworkConnectionFixer] Network fixes applied
✓ [ConnectionDiagnostics] System Healthy
✓ [NetworkDebugger] Connection Approval Request from Client [ID]
✓ [NetworkDebugger] Approval Response: Approved: true
```
## If Still Not Working
### Check These Settings:
**On NetworkManager GameObject:**
- [ ] Player Prefab assigned
- [ ] Network Prefabs list populated
- [ ] Transport component = Unity Transport (UTP)
**On Unity Transport Component:**
- [ ] ConnectionData.Port = 7777 (or your port)
- [ ] ConnectionData.Address = **0.0.0.0** for Host
- [ ] Connect Timeout MS = 15000
- [ ] Max Connect Attempts = 10
**In NetworkManager Inspector (Network Config):**
- [ ] Connection Approval = **checked**
- [ ] Enable Scene Management = **checked**
## Common Mistakes
❌ Using 127.0.0.1 or 192.168.x.x for teammate
✓ Use your PUBLIC IP for teammate
❌ Firewall blocking Unity
✓ Add exception for Unity and your game
❌ Port not actually forwarded
✓ Verify with online port checker
❌ Wrong transport address on host
✓ Host should use 0.0.0.0, client uses YOUR public IP
❌ Player prefab missing NetworkObject
✓ Ensure player prefab has NetworkObject component
## Quick Test Sequence
1. **Test Local:**
- Start Host (connect to 127.0.0.1 from same instance)
- If this fails: Project setup issue
2. **Test LAN:**
- Use 192.168.x.x (local network IP)
- If this fails: Network/Firewall issue
3. **Test Internet:**
- Use public IP
- If this fails: Port forwarding issue
## Console Commands for Diagnostics
Add this to a MonoBehaviour:
```csharp
[ContextMenu("Check Everything")]
void CheckEverything()
{
Debug.Log("IsServer: " + NetworkManager.Singleton.IsServer);
Debug.Log("IsClient: " + NetworkManager.Singleton.IsClient);
Debug.Log("ConnectedClients: " + NetworkManager.Singleton.ConnectedClients.Count);
Debug.Log("Local IP: " + NetworkUtility.GetLocalIPv4());
}
```
## Last Resort Solutions
1. **Use VPN/Hamachi**
- Creates virtual LAN between you and teammate
- No port forwarding needed
- Both connect to VPN IP
2. **Use Unity Relay**
- Built into Unity Netcode
- Bypasses NAT/Firewall completely
- Requires Unity Services account
3. **Host on Cloud Server**
- AWS/Azure/Google Cloud
- Static IP, no port forwarding
- More reliable
## Share These for Help
If still broken, share:
1. Full Console log (Host and Client)
2. Screenshot: NetworkManager inspector
3. Screenshot: Unity Transport settings
4. Port checker result screenshot
5. Windows Firewall rules screenshot
---
**Most likely issue:** Windows Firewall is blocking even with port forwarding.
**Fix:** Run firewall commands in step 2.