Files
Northbound/Assets/Scripts/IMMEDIATE_FIX.md

4.9 KiB

Connection Issue: Immediate Action Plan

Your Problem

Teammate sees "CONNECTED" but gets "Failed to connect to server" error.

Root Cause (Most Likely)

Windows Firewall is blocking Unity/Build even with port forwarding done correctly.

FIX IN 3 STEPS

Step 1: Add Debug Components (1 minute)

Add these to your NetworkManager GameObject in BOTH Host and Client scenes:

  1. ConnectionDiagnostics (automatic check)
  2. NetworkDebugger (detailed logs)
  3. NetworkConnectionFixer (auto-fixes issues)

Step 2: Fix Firewall (2 minutes)

Run PowerShell as Administrator, paste this:

# Allow Unity Editor
netsh advfirewall firewall add rule name="Unity Editor" dir=in action=allow program="C:\Program Files\Unity\Hub\Editor\*\Unity.exe" enable=yes profile=any

# Allow your game build (update 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

Step 3: Verify Port Forwarding (1 minute)

Go to: https://www.yougetsignal.com/tools/open-ports/

  • Enter your PUBLIC IP
  • Enter port 7777
  • Should say: "Port 7777 is open"

If "Closed", your router port forwarding is wrong.


Quick Diagnostics

In Unity Editor (Play Mode):

  1. Add ConnectionDiagnostics to NetworkManager
  2. Right-click component → "Run Diagnostics"
  3. Check console for errors/warnings

Common Diagnostics Results:

  • "System Healthy": Configuration is good, issue is network/firewall
  • ⚠️ "Player Prefab NOT assigned": Assign player prefab in NetworkManager
  • ⚠️ "Connect timeout too low": ConnectionDiagnostics fixes this automatically
  • "NetworkManager not found": Add NetworkManager to scene

If Still Not Working:

Test 1: Local Connection

Host connects to 127.0.0.1 (same instance)

  • Works = Good setup, issue is network
  • Fails = Project setup issue

Test 2: LAN Connection

Host shares 192.168.x.x IP (same WiFi)

  • Works = Good LAN, issue is port forwarding for internet
  • Fails = Firewall blocking local connections

Test 3: Internet Connection

Host shares PUBLIC IP with teammate

  • Works = Fixed!
  • Fails = Port forwarding or remote firewall

What Console Should Show

Host (Working):

[ConnectionDiagnostics] System Healthy
[NetworkConnectionFixer] Network fixes applied
[NetworkDebugger] Server Started Successfully
[NetworkDebugger] Listening on: 0.0.0.0:7777
[NetworkDebugger] Client Connected: 1
[ConnectionHandler] 클라이언트 1 승인됨
[ConnectionHandler] 플레이어 1 스폰됨

Client (Working):

[ConnectionDiagnostics] System Healthy
[NetworkConnectionFixer] Network fixes applied
[NetworkDebugger] Connection Approval Request
[NetworkDebugger] Approval Response: Approved: true
[NetworkDebugger] Client Connected: 0

Client (Broken - Your Case):

[ConnectionDiagnostics] System Healthy
[NetworkConnectionFixer] Network fixes applied
[NetworkDebugger] Connection Approval Request
<color=red>[NetworkDebugger] TRANSPORT FAILURE!</color>
Failed to connect to server

Tools Created for You

File Purpose How to Use
ConnectionDiagnostics.cs Auto-checks configuration Add to scene, right-click "Run Diagnostics"
NetworkDebugger.cs Shows detailed connection logs Add to scene, watch Console during connection
NetworkConnectionFixer.cs Fixes common timeout issues Add to scene, right-click "Fix All Known Issues"
PublicIPHelper.cs Gets your public IP automatically Add to scene, see Inspector

Most Likely Issue: Firewall

Even with correct port forwarding, Windows Firewall blocks:

  1. Port 7777 may be open (router allows it)
  2. But Windows Firewall blocks the application using that port

Solution: Allow Unity and your game through firewall (Step 2)


Alternative: Use Hamachi/VPN

If port forwarding is too complex:

  1. Both install Hamachi: https://www.vpn.net/
  2. Join same Hamachi network
  3. Use Hamachi IP (25.x.x.x) instead of public IP
  4. No port forwarding needed!

Share This for Help

If issue persists, share screenshots/logs:

  1. NetworkManager Inspector (screenshot)
  2. Unity Transport settings (screenshot)
  3. Console log (Host) - after connecting
  4. Console log (Client) - after connection attempt
  5. Port checker result (screenshot)
  6. Windows Firewall rules list (screenshot)

Summary

  1. Add debug components (1 min)
  2. Fix firewall (2 min) - MOST IMPORTANT
  3. Verify port forwarding (1 min)
  4. Test with console logs

If all this fails, the issue is likely:

  • Port forwarding is wrong (verify with online tool)
  • Different Unity/Netcode versions between you and teammate
  • Antivirus/security software blocking

Good luck! 🎮