{"record":{"id":"157abbe201d1de78","repo":"kovidgoyal/kitty","slug":"did-not-receive-expected-streaming-response","errorCode":null,"errorMessage":"Did not receive expected streaming response","messagePattern":"Did not receive expected streaming response","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/cmd/at/socket_io.go","lineNumber":151,"sourceCode":"\t\t\treturn\n\t\t}\n\t\tif len(chunk) == 0 {\n\t\t\tbreak\n\t\t}\n\t\terr = write_many_to_conn(conn, []byte(cmd_escape_code_prefix), chunk, []byte(cmd_escape_code_suffix))\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif !first_escape_code_sent {\n\t\t\tfirst_escape_code_sent = true\n\t\t\tif wants_streaming {\n\t\t\t\tvar streaming_response []byte\n\t\t\t\tstreaming_response, err = r.read_response_from_conn(conn, io_data.timeout)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif !is_stream_response(streaming_response) {\n\t\t\t\t\terr = fmt.Errorf(\"Did not receive expected streaming response\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif io_data.rc.NoResponse {\n\t\treturn\n\t}\n\treturn r.read_response_from_conn(conn, io_data.timeout)\n}\n\nfunc do_socket_io(io_data *rc_io_data) (serialized_response []byte, err error) {\n\tvar conn net.Conn\n\tif global_options.to_network == \"fd\" {\n\t\tfd, _ := strconv.Atoi(global_options.to_address)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/cmd/at/socket_io.go#L133-L169","documentation":"simple_socket_io expected the peer's reply to look like a streaming response (validated by is_stream_response), but the bytes read from the connection did not match that format. This means the connection succeeded and data arrived, but the remote is not speaking the expected streaming protocol (e.g. it replied with a plain/error response instead).","triggerScenarios":"Calling the at tool with streaming mode requested (io_data requests a stream response) against a listener that answers with a non-streaming payload, closes early, or sends a protocol error frame, so is_stream_response(streaming_response) returns false after a successful read_response_from_conn.","commonSituations":"Pointing --to at the wrong port/service (e.g. an HTTP server instead of the expected streaming daemon), a version mismatch between client and server protocol, or a proxy that mangles/truncates the streamed reply.","solutions":["Verify the remote address/network actually serves the expected streaming protocol (test with the same tool version on both ends)","Check that the peer process is the correct version and configured for streaming responses","Capture the bytes returned (log streaming_response) to see what the peer actually sent — often an error message revealing the mismatch","If a proxy sits in the path, bypass it or configure it to pass the stream through unmodified"],"exampleFix":"# before\nat --to tcp:host:9000 --expect-stream\n# after: point at the actual streaming endpoint and matching protocol version\nat --to tcp:host:9001 --expect-stream  # port of the real streaming daemon","handlingStrategy":"validation","validationCode":"// Before requesting streaming mode, probe the peer with a tiny request\n// and confirm the reply matches the streaming protocol.\nresp, err := probe(toAddr)\nif err == nil && !isStreamResponse(resp) {\n    log.Fatalf(\"peer at %s does not speak the streaming protocol; check address/version\", toAddr)\n}","typeGuard":null,"tryCatchPattern":"// In Go: inspect the error text at the call site\nif err != nil && strings.Contains(err.Error(), \"Did not receive expected streaming response\") {\n    // peer reachable but wrong protocol: don't retry, alert on config\n    log.Printf(\"protocol mismatch with %s — verify server version\", addr)\n    return err\n}","preventionTips":["Pin client and server to matching protocol versions","Add a startup handshake/protocol check before relying on streaming replies","Log raw responses when validation fails to speed up diagnosis"],"tags":["network","protocol-mismatch","streaming","go"],"backgroundTag":"protocol-validation-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}