{"record":{"id":"e2b85c8b8df746f5","repo":"XTLS/Xray-core","slug":"failed-to-connect-to-server","errorCode":null,"errorMessage":"failed to connect to server","messagePattern":"failed to connect to server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/shadowsocks_2022/outbound.go","lineNumber":83,"sourceCode":"\t}\n\n\toutbounds := session.OutboundsFromContext(ctx)\n\tob := outbounds[len(outbounds)-1]\n\tif !ob.Target.IsValid() {\n\t\treturn errors.New(\"target not specified\")\n\t}\n\tob.Name = \"shadowsocks-2022\"\n\tob.CanSpliceCopy = 3\n\tdestination := ob.Target\n\tnetwork := destination.Network\n\n\terrors.LogInfo(ctx, \"tunneling request to \", destination, \" via \", o.server.NetAddr())\n\n\tserverDestination := o.server\n\tserverDestination.Network = network\n\tconnection, err := dialer.Dial(ctx, serverDestination)\n\tif err != nil {\n\t\treturn errors.New(\"failed to connect to server\").Base(err)\n\t}\n\n\tif session.TimeoutOnlyFromContext(ctx) {\n\t\tctx, _ = context.WithCancel(context.Background())\n\t}\n\n\tif network == net.Network_TCP {\n\t\tserverConn := o.method.DialEarlyConn(connection, singbridge.ToSocksaddr(destination))\n\t\tvar handshake bool\n\t\tif timeoutReader, isTimeoutReader := link.Reader.(buf.TimeoutReader); isTimeoutReader {\n\t\t\tmb, err := timeoutReader.ReadMultiBufferTimeout(time.Millisecond * 100)\n\t\t\tif err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout {\n\t\t\t\treturn errors.New(\"read payload\").Base(err)\n\t\t\t}\n\t\t\tpayload := B.New()\n\t\t\tfor {\n\t\t\t\tpayload.Reset()\n\t\t\t\tnb, n := buf.SplitBytes(mb, payload.FreeBytes())","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/shadowsocks_2022/outbound.go#L65-L101","documentation":"Shadowsocks-2022 outbound Process fails dialing the configured server destination through the provided dialer; the chained network error indicates the server is unreachable before any protocol bytes are exchanged.","triggerScenarios":"Thrown at proxy/shadowsocks_2022/outbound.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check server address/port and network reachability","Inspect .Base(err) for DNS, timeout, or TLS/stream errors","Confirm streamSettings on the outbound are correct"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","contentChangedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}