{"record":{"id":"ca5fd044171c30ae","repo":"XTLS/Xray-core","slug":"reading-local-failed-to-parse-address-and-port","errorCode":null,"errorMessage":"reading local: failed to parse address and port","messagePattern":"reading local: failed to parse address and port","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/mux/frame.go","lineNumber":201,"sourceCode":"\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)\n\t\taddr, port, err = addrParser.ReadAddressPort(nil, b)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"reading local: failed to parse address and port\").Base(err)\n\t\t}\n\t\tswitch network {\n\t\tcase TargetNetworkTCP:\n\t\t\tf.Inbound.Local = net.TCPDestination(addr, port)\n\t\tcase TargetNetworkUDP:\n\t\t\tf.Inbound.Local = net.UDPDestination(addr, port)\n\t\tdefault:\n\t\t\treturn errors.New(\"reading local: unknown network type: \", network)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// Application data is essential, to test whether the pipe is closed.\n\tif f.SessionStatus == SessionStatusNew && f.Option.Has(OptionData) &&\n\t\tf.Target.Network == net.Network_UDP && b.Len() >= 8 {\n\t\tcopy(f.GlobalID[:], b.Bytes())\n\t}","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/mux/frame.go#L183-L219","documentation":"While unmarshalling the optional inbound local-address block (the second optional address after the source address, only when readSourceAndLocal is true), addrParser.ReadAddressPort failed. The frame's trailing bytes claim to be a local address but do not decode as one.","triggerScenarios":"A SessionStatusNew frame with readSourceAndLocal=true where, after a valid source address, the next non-zero network byte is followed by a malformed address; also happens when extra trailing bytes (padding written by a different version) are mistaken for a local address block.","commonSituations":"Reverse-mux interoperability between different Xray versions, or clients that append arbitrary padding after the source address.","solutions":["Match Xray-core versions across the reverse-mux tunnel.","Verify the client writes a 0 byte (padding) when it has no local address to send.","Hexdump the failing frame tail to check for unexpected padding.","Disable the feature/path that sets readSourceAndLocal to confirm the diagnosis."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := meta.Unmarshal(reader, true); err != nil {\n    return err // stream trust is gone; close the connection","preventionTips":["Terminate frame payloads correctly: write padding 0 when local address is absent.","Do not append arbitrary trailing bytes to New frames.","Test reverse-mux frames with and without optional addresses."],"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"}