{"record":{"id":"5811f92157e7e1f6","repo":"txthinking/brook","slug":"cannot-create-exchanger-from","errorCode":null,"errorMessage":"cannot create exchanger from ","messagePattern":"cannot create exchanger from ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"brooklink.go","lineNumber":276,"sourceCode":"\t\t}\n\t\trc, err := QUICDialUDP(src, socks5.ToAddress(dstb[0], dstb[1:len(dstb)-2], dstb[len(dstb)-2:]), blk.Address, blk.Tc, udptimeout)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tvar sc Exchanger\n\t\tif blk.V.Get(\"withoutBrookProtocol\") != \"true\" {\n\t\t\tsc, err = NewPacketClient(blk.Password, src, rc, udptimeout, dstb)\n\t\t}\n\t\tif blk.V.Get(\"withoutBrookProtocol\") == \"true\" {\n\t\t\tsc, err = NewSimplePacketClient(blk.Password, src, rc, udptimeout, dstb)\n\t\t}\n\t\tif err != nil {\n\t\t\trc.Close()\n\t\t\treturn nil, nil, err\n\t\t}\n\t\treturn sc, rc, nil\n\t}\n\treturn nil, nil, errors.New(\"cannot create exchanger from \" + blk.Kind)\n}\n\nfunc (x *BrookLink) PrepareSocks5Server(addr, ip string, tcptimeout, udptimeout int) error {\n\tif err := limits.Raise(); err != nil {\n\t\tLog(Error{\"when\": \"try to raise system limits\", \"warning\": err.Error()})\n\t}\n\tif x.Kind == \"quicserver\" {\n\t\tif runtime.GOOS == \"linux\" {\n\t\t\tc := exec.Command(\"sysctl\", \"-w\", \"net.core.rmem_max=2500000\")\n\t\t\tb, err := c.CombinedOutput()\n\t\t\tif err != nil {\n\t\t\t\tLog(Error{\"when\": \"try to raise UDP Receive Buffer Size\", \"warning\": string(b)})\n\t\t\t}\n\t\t}\n\t\tif runtime.GOOS == \"darwin\" {\n\t\t\tc := exec.Command(\"sysctl\", \"-w\", \"kern.ipc.maxsockbuf=3014656\")\n\t\t\tb, err := c.CombinedOutput()\n\t\t\tif err != nil {","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/brooklink.go#L258-L294","documentation":"CreateExchanger dispatches on the brook link's Kind to build a client/server exchanger pair. If the kind does not match any supported scheme (ws, wss, quic, etc.), it returns this error with the unrecognized kind appended. It means the link string's scheme prefix is not a protocol this build supports.","triggerScenarios":"Calling CreateExchanger (directly or via TCPHandle/UDPHandle) with a BrookLink whose Kind string is unknown — e.g. a typo'd or unsupported scheme like 'ws4ss://', an empty scheme, or a scheme added in a newer brook version.","commonSituations":"Hand-crafted brook:// link strings with wrong scheme; links generated by newer brook clients passed to an older library; empty/malformed link URL where scheme parsing yields \"\" (note the double space in the message when Kind is empty).","solutions":["Print/inspect blk.Kind and correct the scheme in the link string to a supported one (ws, wss, quic, etc.)","Regenerate the link with a matching brook version so the scheme is recognized","Upgrade the library if the link uses a newer protocol kind your build doesn't support","If Kind is empty, check that the link URL was parsed correctly and has a scheme prefix"],"exampleFix":"// before\nblk, _ := NewBrookLink(\"ws4ss://server:443?something\")\nex := CreateExchanger(blk)\n// after\nblk, _ := NewBrookLink(\"wss://server:443?withoutHeader=true\")\nex := CreateExchanger(blk)","handlingStrategy":"validation","validationCode":"supported := map[string]bool{\"ws\": true, \"wss\": true, \"quic\": true /* per your build */}\nif !supported[blk.Kind] {\n\treturn fmt.Errorf(\"unsupported brook kind: %q\", blk.Kind)\n}","typeGuard":null,"tryCatchPattern":"sc, rc, err := CreateExchanger(blk)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"cannot create exchanger from\") {\n\t\tlog.Printf(\"unknown brook kind %q — check link scheme\", blk.Kind)\n\t}\n\treturn err\n}","preventionTips":["Generate links with the same brook version as the consuming library","Validate scheme prefix before constructing links","Log blk.Kind on failure to spot typos/empty schemes"],"tags":["unsupported-protocol","link-parsing","brook"],"backgroundTag":"invalid-enum-value","analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}