{"record":{"id":"8c06a4b1f6d0a588","repo":"wavetermdev/waveterm","slug":"stream-broker-not-available","errorCode":null,"errorMessage":"stream broker not available","messagePattern":"stream broker not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-file-util.go","lineNumber":96,"sourceCode":"\n\t\t// Prepare and send chunk\n\t\tchunk := buf[:n]\n\t\tappendData := fileData\n\t\tappendData.Data64 = base64.StdEncoding.EncodeToString(chunk)\n\n\t\terr = wshclient.FileAppendCommand(RpcClient, appendData, &wshrpc.RpcOpts{Timeout: int64(fileTimeout)})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"appending chunk to file: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc streamReadFromFile(ctx context.Context, fileData wshrpc.FileData, writer io.Writer) error {\n\tbroker := RpcClient.StreamBroker\n\tif broker == nil {\n\t\treturn fmt.Errorf(\"stream broker not available\")\n\t}\n\tif fileData.Info == nil {\n\t\treturn fmt.Errorf(\"file info is required\")\n\t}\n\treaderRouteId := RpcClientRouteId\n\tif readerRouteId == \"\" {\n\t\treturn fmt.Errorf(\"no route id available\")\n\t}\n\tconn, err := connparse.ParseURI(fileData.Info.Path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing file path: %w\", err)\n\t}\n\twriterRouteId := wshutil.MakeConnectionRouteId(conn.Host)\n\treader, streamMeta := broker.CreateStreamReader(readerRouteId, writerRouteId, 256*1024)\n\tdefer reader.Close()\n\tgo func() {\n\t\t<-ctx.Done()\n\t\treader.Close()","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-file-util.go#L78-L114","documentation":"streamReadFromFile (used by `wsh cat`) relies on RpcClient.StreamBroker to multiplex streaming data. If the broker was never installed on the RPC client, there is no transport for the streamed file data and the call fails immediately with \"stream broker not available\".","triggerScenarios":"Running `wsh cat` (fileCatRun) when RpcClient.StreamBroker is nil — e.g. a wsh client built/connected without stream support, an older server or client version mismatch, or an embedded/test RPC client that skipped broker wiring.","commonSituations":"Stale or mismatched wsh binary on a remote host predating stream support; custom tooling reusing the wsh RPC client without registering a StreamBroker; regression after partial upgrade of Wave/wsh on one side.","solutions":["Update wsh on both local and remote ends to matching current versions so the stream broker is installed.","Reconnect the wsh client (open a fresh Wave block / re-run preRunSetupRpcClient) and retry.","Fall back to non-streaming read paths (`wsh file read` style commands) if supported by your version.","If embedding the RPC client, register a StreamBroker (wshutil) before issuing FileStreamCommand-dependent calls."],"exampleFix":"// before (custom client setup)\nrpcClient := wshutil.MakeRpcClient(routeId) // no broker\n// after\nrpcClient := wshutil.MakeRpcClient(routeId)\nrpcClient.SetStreamBroker(wshutil.MakeLocalStreamBroker())","handlingStrategy":"type-guard","validationCode":"if RpcClient == nil || RpcClient.StreamBroker == nil {\n    return fmt.Errorf(\"streaming unsupported by this client; update wsh or use non-streaming read\")\n}","typeGuard":"func streamCapable(c *wshutil.WshRpc) bool {\n    return c != nil && c.StreamBroker != nil\n}","tryCatchPattern":"if err := streamReadFromFile(ctx, fileData, writer); err != nil {\n    if strings.Contains(err.Error(), \"stream broker not available\") {\n        // fallback: use FileReadCommand-based read path\n    }\n}","preventionTips":["Keep wsh versions identical on local and remote ends","Register a StreamBroker when embedding the wsh RPC client","Re-establish the RPC client (new Wave block) if broker is missing","Prefer the non-streaming read API for minimal clients"],"tags":["streaming","rpc","version-mismatch"],"backgroundTag":"stream-broker-unavailable","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}