{"record":{"id":"3cd3568ffea9b388","repo":"AlexxIT/go2rtc","slug":"rtmp-wrong-response-v","errorCode":null,"errorMessage":"rtmp: wrong response %#v","messagePattern":"rtmp: wrong response %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rtmp/conn.go","lineNumber":262,"sourceCode":"\tb := amf.EncodeItems(\"connect\", 1, map[string]any{\n\t\t\"app\":      c.App,\n\t\t\"flashVer\": \"FMLE/3.0 (compatible; FMSc/1.0)\",\n\t\t\"tcUrl\":    c.url,\n\t})\n\tif err := c.writeMessage(3, TypeCommand, 0, b); err != nil {\n\t\treturn err\n\t}\n\n\tv, err := c.readResponse(func(items []any) bool {\n\t\treturn len(items) >= 3 && items[0] == \"_result\" && items[1] == float64(1)\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcode := getString(v, 3, \"code\")\n\tif code != \"NetConnection.Connect.Success\" {\n\t\treturn fmt.Errorf(\"rtmp: wrong response %#v\", v)\n\t}\n\n\treturn nil\n}\n\nfunc (c *Conn) writeReleaseStream() error {\n\tb := amf.EncodeItems(\"releaseStream\", 2, nil, c.Stream)\n\tif err := c.writeMessage(3, TypeCommand, 0, b); err != nil {\n\t\treturn err\n\t}\n\tb = amf.EncodeItems(\"FCPublish\", 3, nil, c.Stream)\n\tif err := c.writeMessage(3, TypeCommand, 0, b); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\nfunc (c *Conn) writeCreateStream() error {\n\tb := amf.EncodeItems(\"createStream\", 4, nil)","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/rtmp/conn.go#L244-L280","documentation":"After sending the RTMP \"connect\" command, writeConnect reads the server's result message and checks that code equals \"NetConnection.Connect.Success\". Any other code (e.g. NetConnection.Connect.Rejected, _error) means the handshake failed, so the library returns this error with the full decoded response for diagnosis. It indicates the RTMP server refused or could not complete the connection.","triggerScenarios":"Calling play or publish against an RTMP URL where the server rejects the connect command: wrong app name, authentication required, invalid credentials in the URL, server at capacity, or a non-RTMP service on the port.","commonSituations":"Streaming to a platform with expired/incorrect stream key embedded in the URL; wrong application path (e.g. /live vs /app); firewall or proxy interfering; connecting to an RTMPS-only endpoint over plain RTMP.","solutions":["Inspect the %#v response in the error — the \"code\" and \"description\" fields say why the connect was rejected.","Verify the RTMP URL, application name, and stream key are correct and unexpired.","If the server requires RTMPS/TLS, switch the URL scheme to rtmps://.","Confirm the port (default 1935) is reachable and the server is actually an RTMP service."],"exampleFix":"// before\nc, _ := rtmp.Dial(\"rtmp://server/live\")\nc.connect(\"wrong-app\", false)\n// after\nc, _ := rtmp.Dial(\"rtmp://server/live\")\nc.connect(\"live\", false) // app name must match the server-side application","handlingStrategy":"try-catch","validationCode":"u, err := url.Parse(rtmpURL)\nif err != nil || u.Scheme != \"rtmp\" && u.Scheme != \"rtmps\" {\n    return fmt.Errorf(\"invalid RTMP URL: %q\", rtmpURL)\n}","typeGuard":null,"tryCatchPattern":"if err := conn.writeConnect(app, tls); err != nil {\n    if strings.Contains(err.Error(), \"wrong response\") {\n        // log the %#v response; check code/description for reject reason\n    }\n    return err\n}","preventionTips":["Validate RTMP URLs, app names, and stream keys before connecting.","Use rtmps:// when the server requires TLS.","Test connectivity to port 1935 with a known-good client first."],"tags":["rtmp","streaming","handshake","network"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}