{"record":{"id":"c9d8e08e949dab73","repo":"fatedier/frp","slug":"send-newvisitorconnmsg-to-server-error-v","errorCode":null,"errorMessage":"send newVisitorConnMsg to server error: %v","messagePattern":"send newVisitorConnMsg to server error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/visitor/visitor.go","lineNumber":184,"sourceCode":"\tvisitorConn, err := v.helper.ConnectServer()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"connect to server error: %v\", err)\n\t}\n\n\tnow := time.Now().Unix()\n\ttargetProxyName := naming.BuildTargetServerProxyName(v.clientCfg.User, cfg.ServerUser, cfg.ServerName)\n\tnewVisitorConnMsg := &msg.NewVisitorConn{\n\t\tRunID:          v.helper.RunID(),\n\t\tProxyName:      targetProxyName,\n\t\tSignKey:        util.GetAuthKey(cfg.SecretKey, now),\n\t\tTimestamp:      now,\n\t\tUseEncryption:  cfg.Transport.UseEncryption,\n\t\tUseCompression: cfg.Transport.UseCompression,\n\t}\n\terr = visitorConn.WriteMsg(newVisitorConnMsg)\n\tif err != nil {\n\t\tvisitorConn.Close()\n\t\treturn nil, fmt.Errorf(\"send newVisitorConnMsg to server error: %v\", err)\n\t}\n\n\t_ = visitorConn.SetReadDeadline(time.Now().Add(10 * time.Second))\n\tvar newVisitorConnRespMsg msg.NewVisitorConnResp\n\terr = visitorConn.ReadMsgInto(&newVisitorConnRespMsg)\n\tif err != nil {\n\t\tvisitorConn.Close()\n\t\treturn nil, fmt.Errorf(\"read newVisitorConnRespMsg error: %v\", err)\n\t}\n\t_ = visitorConn.SetReadDeadline(time.Time{})\n\n\tif newVisitorConnRespMsg.Error != \"\" {\n\t\tvisitorConn.Close()\n\t\treturn nil, fmt.Errorf(\"start new visitor connection error: %s\", newVisitorConnRespMsg.Error)\n\t}\n\treturn visitorConn, nil\n}\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/client/visitor/visitor.go#L166-L202","documentation":"Visitor failed to write the NewVisitorConn control message to the frps server over the visitor connection. The message carries the run ID, target proxy name, an auth signature derived from the secret key, and encryption/compression flags. A write error means the underlying TCP/TLS stream to the server is broken or was closed before/during the send.","triggerScenarios":"visitorConn.WriteMsg(newVisitorConnMsg) returns non-nil: connection reset by the server, TLS handshake failure surfacing on first write, network drop between visitor and frps, or the server closing the connection immediately after accept.","commonSituations":"frps restarted or crashed while the frpc visitor was dialing; wrong serverPort/TLS settings so the peer is not actually frps; a firewall or NAT silently dropping the established flow; secret key mismatch causing the server to close early.","solutions":["Check frps is running and reachable: verify serverAddr/serverPort and that transport.tls settings match between frpc and frps.","Inspect frps logs at the same timestamp; the server side usually logs why it dropped the visitor connection.","Check network path stability between the visitor host and the server (firewall, NAT timeout, middlebox interference on the port).","Confirm the visitor's secretKey matches the server; a bad signature is often rejected by closing the connection.","frpc retries visitor connections automatically; persistent recurrence points to a systematic config problem rather than a one-off blip."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight the server before enabling visitors\nconn, err := net.DialTimeout(\"tcp\",\n    fmt.Sprintf(\"%s:%d\", cfg.ServerAddr, cfg.ServerPort), 5*time.Second)\nif err != nil { /* surface friendly error, skip visitor start */ }\nconn.Close()","typeGuard":null,"tryCatchPattern":"// Treat any error from the visitor dial as fatal for that attempt;\n// the visitor manager already retries with backoff — log and return.\nif _, err := v.newVisitorConn(ctx); err != nil {\n    xl.Warnf(\"visitor dial failed, will retry: %v\", err)\n}","preventionTips":["Keep frpc/frps versions matched","Verify serverAddr/serverPort/TLS flags before deploying visitors","Monitor frps health so visitors fail fast against a healthy server"],"tags":["network","visitor","frpc","connection"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}