{"record":{"id":"14be50d2f7f26ef3","repo":"snail007/goproxy","slug":"client-control-conn-not-exists","errorCode":null,"errorMessage":"client control conn not exists","messagePattern":"client control conn not exists","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"services/tunnel_bridge.go","lineNumber":155,"sourceCode":"\treturn\n}\nfunc (s *TunnelBridge) ChnDeamon(item *BridgeItem) {\n\tgo func() {\n\t\tlog.Printf(\"%s conn chan deamon started\", item.Key)\n\t\tfor {\n\t\t\tvar clientConn *net.Conn\n\t\t\tvar serverConn *net.Conn\n\t\t\tserverConn = <-item.ServerChn\n\t\t\tlog.Printf(\"%s server conn picked up\", item.Key)\n\t\tOUT:\n\t\t\tfor {\n\t\t\t\t_item, _ := s.br.Get(item.Key)\n\t\t\t\tItem := _item.(*BridgeItem)\n\t\t\t\tvar err error\n\t\t\t\tif Item.ClientControl != nil && *Item.ClientControl != nil {\n\t\t\t\t\t_, err = (*Item.ClientControl).Write([]byte{'0'})\n\t\t\t\t} else {\n\t\t\t\t\terr = fmt.Errorf(\"client control conn not exists\")\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"%s client control conn write signal fail, err: %s, retrying...\", item.Key, err)\n\t\t\t\t\tutils.CloseConn(Item.ClientControl)\n\t\t\t\t\t*Item.ClientControl = nil\n\t\t\t\t\tItem.ClientControl = nil\n\t\t\t\t\ttime.Sleep(time.Second * 3)\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tselect {\n\t\t\t\t\tcase clientConn = <-item.ClientChn:\n\t\t\t\t\t\tlog.Printf(\"%s client conn picked up\", item.Key)\n\t\t\t\t\t\tbreak OUT\n\t\t\t\t\tcase <-time.After(time.Second * time.Duration(*s.cfg.Timeout*5)):\n\t\t\t\t\t\tlog.Printf(\"%s client conn picked timeout, retrying...\", item.Key)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/snail007/goproxy/blob/e6d6a821db80e7f47ee6e981a144984e1d4ddb3d/services/tunnel_bridge.go#L137-L173","documentation":"The bridge periodically writes a signal byte to each client's control connection. This error is produced when a BridgeItem exists but its ClientControl connection pointer is nil, meaning the client's control channel was never established or was already closed, so the signal cannot be sent and the item is cleaned up and retried.","triggerScenarios":"During the bridge scan loop, Item.ClientControl is nil (or points to a nil conn) when the code tries to Write the '0' signal; typically after the client disconnected, before registration completed, or after a previous failure nil-ed the pointer.","commonSituations":"Client behind flaky NAT/network dropped its control connection; client crashed or was restarted while server-side bridge item lingered; firewall idle-timeout killed the long-lived control connection; client never finished connecting due to wrong key/address.","solutions":["Restart/reconnect the client so it re-establishes its control connection","Check client-to-server connectivity and keep-alive settings so the control connection is not idle-killed by firewalls/NAT","Verify the client is running a compatible version and its control port/key config matches the server","Inspect server logs just before this error to find why the control conn was closed and address that root cause"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before relying on a bridge, verify the client control channel is registered:\nitem, ok := bridge.Get(key)\nif !ok || item.ClientControl == nil || *item.ClientControl == nil {\n    // wait/retry for the client to (re)register instead of signaling\n    time.Sleep(time.Second)\n}","typeGuard":null,"tryCatchPattern":"// server-side is a log+retry loop; on the client, wrap reconnects:\nfor {\n    err := client.ConnectAndServe()\n    if err != nil {\n        log.Printf(\"control conn lost: %v; reconnecting in 3s\", err)\n        time.Sleep(3 * time.Second)\n        continue\n    }\n    break\n}","preventionTips":["Enable TCP keepalives on control connections to survive NAT/firewall idle timeouts","Run the client under a supervisor (systemd) that restarts it on exit","Monitor server logs for this message as an early sign of client instability","Keep client and server versions in sync to avoid protocol registration mismatches"],"tags":["tunnel","connection-state","bridge","control-channel"],"backgroundTag":"control-connection-lost","analyzedSha":"e6d6a821db80e7f47ee6e981a144984e1d4ddb3d","analyzedAt":"2026-09-03T15:32:42.750Z","contentChangedAt":"2026-09-03T15:32:42.750Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}