{"record":{"id":"6316e557b3395218","repo":"XTLS/Xray-core","slug":"reading-source-failed-to-parse-address-and-port","errorCode":null,"errorMessage":"reading source: failed to parse address and port","messagePattern":"reading source: failed to parse address and port","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/mux/frame.go","lineNumber":180,"sourceCode":"\t\tdefault:\n\t\t\treturn errors.New(\"unknown network type: \", network)\n\t\t}\n\t}\n\n\tif f.SessionStatus == SessionStatusNew && readSourceAndLocal {\n\t\tf.Inbound = &session.Inbound{}\n\n\t\tif b.Len() == 0 {\n\t\t\treturn nil // for heartbeat, etc.\n\t\t}\n\t\tnetwork := TargetNetwork(b.Byte(0))\n\t\tif network == 0 {\n\t\t\treturn nil // may be padding\n\t\t}\n\t\tb.Advance(1)\n\t\taddr, port, err := addrParser.ReadAddressPort(nil, b)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"reading source: failed to parse address and port\").Base(err)\n\t\t}\n\t\tswitch network {\n\t\tcase TargetNetworkTCP:\n\t\t\tf.Inbound.Source = net.TCPDestination(addr, port)\n\t\tcase TargetNetworkUDP:\n\t\t\tf.Inbound.Source = net.UDPDestination(addr, port)\n\t\tdefault:\n\t\t\treturn errors.New(\"reading source: unknown network type: \", network)\n\t\t}\n\n\t\tif b.Len() == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tnetwork = TargetNetwork(b.Byte(0))\n\t\tif network == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tb.Advance(1)","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/mux/frame.go#L162-L198","documentation":"While unmarshalling the optional inbound-source section of a SessionStatusNew frame (only read when readSourceAndLocal is true, e.g. reverse mux), addrParser.ReadAddressPort failed on the source address. The frame carries a source-address block that is not valid Xray address encoding.","triggerScenarios":"Reverse-mux (or any path passing readSourceAndLocal=true) receives a New frame whose post-metadata bytes begin with a network byte plus a malformed address; also triggered when optional padding/heartbeat bytes are misinterpreted as a source address.","commonSituations":"Reverse proxy mux where the client version does not write source/local addresses the way the server expects them, or stream corruption inside a reverse-mux tunnel.","solutions":["Ensure both ends of the reverse-mux tunnel run the same Xray-core version (source/local encoding changed over time).","Reproduce with readSourceAndLocal disabled (non-reverse mux) to isolate whether the optional source block is the problem.","Inspect the raw frame bytes: after the target address, the first byte must be 0 (padding/heartbeat) or a valid network byte followed by a well-formed address+port.","Check for middleware or obfuscation layers that could reorder/truncate the payload."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := meta.Unmarshal(reader, session.IsReverseMuxFromContext(ctx)); err != nil {\n    // any source-address parse failure means the stream is unusable\n    return err // closes mux connection via run loop\n}","preventionTips":["Match versions on both ends of reverse mux.","Clients: write a 0 byte when no source address is present, per protocol.","Avoid inserting extra bytes after the target address in New frames."],"tags":["mux","reverse-proxy","parsing","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}