AlexxIT/go2rtc · error
rtmp: wrong response %#v
Error message
rtmp: wrong response %#v
What it means
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.
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.
Example fix
// before
c, _ := rtmp.Dial("rtmp://server/live")
c.connect("wrong-app", false)
// after
c, _ := rtmp.Dial("rtmp://server/live")
c.connect("live", false) // app name must match the server-side application Defensive patterns
Strategy: try-catch
Validate before calling
u, err := url.Parse(rtmpURL)
if err != nil || u.Scheme != "rtmp" && u.Scheme != "rtmps" {
return fmt.Errorf("invalid RTMP URL: %q", rtmpURL)
} Try / catch
if err := conn.writeConnect(app, tls); err != nil {
if strings.Contains(err.Error(), "wrong response") {
// log the %#v response; check code/description for reject reason
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- wrong response:
- av login 2 failed
- dtls: server handshake failed
- dtls: client handshake failed
- miss: read media
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/3cd3568ffea9b388.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/rtmp/conn.go:262
b := amf.EncodeItems("connect", 1, map[string]any{
"app": c.App,
"flashVer": "FMLE/3.0 (compatible; FMSc/1.0)",
"tcUrl": c.url,
})
if err := c.writeMessage(3, TypeCommand, 0, b); err != nil {
return err
}
v, err := c.readResponse(func(items []any) bool {
return len(items) >= 3 && items[0] == "_result" && items[1] == float64(1)
})
if err != nil {
return err
}
code := getString(v, 3, "code")
if code != "NetConnection.Connect.Success" {
return fmt.Errorf("rtmp: wrong response %#v", v)
}
return nil
}
func (c *Conn) writeReleaseStream() error {
b := amf.EncodeItems("releaseStream", 2, nil, c.Stream)
if err := c.writeMessage(3, TypeCommand, 0, b); err != nil {
return err
}
b = amf.EncodeItems("FCPublish", 3, nil, c.Stream)
if err := c.writeMessage(3, TypeCommand, 0, b); err != nil {
return err
}
return nil
}
func (c *Conn) writeCreateStream() error {
b := amf.EncodeItems("createStream", 4, nil)View on GitHub (pinned to c245815e75)