|
| 1 | +# Troubleshooting |
| 2 | + |
| 3 | +`coder ping <workspace>` will ping the workspace agent and print diagnostics on |
| 4 | +the state of the connection. These diagnostics are created by inspecting both |
| 5 | +the client and agent network configurations, and provide insights into why a |
| 6 | +direct connection may be impeded, or why the quality of one might be degraded. |
| 7 | + |
| 8 | +The `-v/--verbose` flag can be appended to the command to print client debug |
| 9 | +logs. |
| 10 | + |
| 11 | +```console |
| 12 | +$ coder ping dev |
| 13 | +pong from workspace proxied via DERP(Council Bluffs, Iowa) in 42ms |
| 14 | +pong from workspace proxied via DERP(Council Bluffs, Iowa) in 41ms |
| 15 | +pong from workspace proxied via DERP(Council Bluffs, Iowa) in 39ms |
| 16 | +✔ preferred DERP region: 999 (Council Bluffs, Iowa) |
| 17 | +✔ sent local data to Coder networking coordinator |
| 18 | +✔ received remote agent data from Coder networking coordinator |
| 19 | + preferred DERP region: 999 (Council Bluffs, Iowa) |
| 20 | + endpoints: x.x.x.x:46433, x.x.x.x:46433, x.x.x.x:46433 |
| 21 | +✔ Wireguard handshake 11s ago |
| 22 | + |
| 23 | +❗ You are connected via a DERP relay, not directly (p2p) |
| 24 | +Possible client-side issues with direct connection: |
| 25 | + - Network interface utun0 has MTU 1280, (less than 1378), which may degrade the quality of direct connections |
| 26 | + |
| 27 | +Possible agent-side issues with direct connection: |
| 28 | + - Agent is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers |
| 29 | + - Agent IP address is within an AWS range (AWS uses hard NAT) |
| 30 | +``` |
| 31 | + |
| 32 | +## Common Problems |
| 33 | + |
| 34 | +### Direct Connections Disabled Deployment-Wide |
| 35 | + |
| 36 | +Direct connections can be disabled at the deployment level by setting the |
| 37 | +`CODER_BLOCK_DIRECT` environment variable or the `--block-direct-connections` |
| 38 | +flag on the server. When set, this will be reflected in the output of |
| 39 | +`coder ping`. |
| 40 | + |
| 41 | +### Firewall Blocks UDP |
| 42 | + |
| 43 | +Some corporate firewalls block UDP traffic. Direct connections require UDP |
| 44 | +traffic to be allowed between the client and agent, as well as between the |
| 45 | +client/agent and STUN servers in most cases. `coder ping` will indicate if |
| 46 | +either the Coder agent or client had issues sending or receiving UDP packets to |
| 47 | +STUN servers. |
| 48 | + |
| 49 | +If this is the case, you may need to add exceptions to the firewall to allow UDP |
| 50 | +for Coder workspaces, clients, and STUN servers. |
| 51 | + |
| 52 | +### Endpoint-Dependent NAT (Hard NAT) |
| 53 | + |
| 54 | +Hard NATs prevent public endpoints gathered from STUN servers from being used by |
| 55 | +the peer to establish a direct connection. Typically, if only one side of the |
| 56 | +connection is behind a hard NAT, direct connections can still be established |
| 57 | +easily. However, if both sides are behind hard NATs, direct connections may take |
| 58 | +longer to establish or may not be possible at all. |
| 59 | + |
| 60 | +Hard NATs may also be simulated by firewalls that block ingress traffic from |
| 61 | +unknown 5-tuples (Protocol, Source IP, Source Port, Destination IP, Destination |
| 62 | +Port). |
| 63 | + |
| 64 | +`coder ping` will indicate if it's possible the client or agent is behind a hard |
| 65 | +NAT or if a firewall is exhibiting this behavior. |
| 66 | + |
| 67 | +Learn more about [STUN and NAT](./stun.md). |
| 68 | + |
| 69 | +### VPNs |
| 70 | + |
| 71 | +If a VPN is the default route for all IP traffic, it may interfere with the |
| 72 | +ability for clients and agents to form direct connections. This happens if the |
| 73 | +NAT does not permit traffic to be |
| 74 | +['hairpinned'](./stun.md#3-direct-connections-with-vpn-and-nat-hairpinning) from |
| 75 | +the public IP address of the NAT (determined via STUN) to the internal IP |
| 76 | +address of the agent. |
| 77 | + |
| 78 | +If this is the case, you may need to add exceptions to the VPN for Coder, modify |
| 79 | +the NAT configuration, or deploy an internal STUN server. |
| 80 | + |
| 81 | +### Low MTU |
| 82 | + |
| 83 | +If a network interface on the side of either the client or agent has an MTU |
| 84 | +smaller than 1378, any direct connections form may have degraded quality or |
| 85 | +performance, as IP packets are fragmented. `coder ping` will indicate if this is |
| 86 | +the case by inspecting network interfaces on both the client and the workspace |
| 87 | +agent. |
| 88 | + |
| 89 | +If another interface cannot be used, and the MTU cannot be changed, you may need |
| 90 | +to disable direct connections, and relay all traffic via DERP instead, which |
| 91 | +will not be affected by the low MTU. |
| 92 | + |
| 93 | +## Throughput |
| 94 | + |
| 95 | +The `coder speedtest <workspace>` command measures the throughput between the |
| 96 | +client and the workspace agent. |
| 97 | + |
| 98 | +```console |
| 99 | +$ coder speedtest workspace |
| 100 | +29ms via coder |
| 101 | +Starting a 5s download test... |
| 102 | +INTERVAL TRANSFER BANDWIDTH |
| 103 | +0.00-1.00 sec 630.7840 MBits 630.7404 Mbits/sec |
| 104 | +1.00-2.00 sec 913.9200 MBits 913.8106 Mbits/sec |
| 105 | +2.00-3.00 sec 943.1040 MBits 943.0399 Mbits/sec |
| 106 | +3.00-4.00 sec 933.3760 MBits 933.2143 Mbits/sec |
| 107 | +4.00-5.00 sec 848.8960 MBits 848.7019 Mbits/sec |
| 108 | +5.00-5.02 sec 13.5680 MBits 828.8189 Mbits/sec |
| 109 | +---------------------------------------------------- |
| 110 | +0.00-5.02 sec 4283.6480 MBits 853.8217 Mbits/sec |
| 111 | +``` |
0 commit comments