AlexxIT/go2rtc · error

wrong user/pass

Error message

wrong user/pass

What it means

The RTSP client sent a request and got a 401 Unauthorized response, and it cannot retry with new auth material. The auth layer already holds a concrete credential method (Basic or Digest), re-sent the request with those credentials, and the server rejected them again, so Do() aborts with "wrong user/pass". It means the username/password embedded in the RTSP URL (or set via auth) is incorrect or does not match the server's auth scheme.

Solutions

  1. Check the username/password in the RTSP URL and verify them against the camera/server settings (e.g. log in to the camera web UI with the same credentials).
  2. URL-encode special characters in the password (e.g. @ -> %40, : -> %3A) inside the RTSP URL.
  3. Reset the camera credentials to a known value and update the URL.
  4. Test the URL with an independent tool (ffplay/vlc) to confirm the credentials work outside this library.
  5. If the server requires an auth scheme the library's tcp.Auth cannot parse, check the server's Www-Authenticate header and its configuration.

Example fix

// before
client, _ := rtsp.Dial("rtsp://admin:p@ss:word@192.168.1.10/stream")
// after (URL-encode special chars)
client, _ := rtsp.Dial("rtsp://admin:p%40ss%3Aword@192.168.1.10/stream")
Defensive patterns

Strategy: try-catch

Validate before calling

u, _ := url.Parse(rtspURL)
if u.User == nil || u.User.Username() == "" {
    return fmt.Errorf("RTSP URL must include credentials: %s", rtspURL)
}

Try / catch

res, err := client.Describe()
if err != nil && strings.Contains(err.Error(), "wrong user/pass") {
    // prompt user for correct credentials / fail fast with clear message
}

Prevention

When it happens

Trigger: Calling client methods Options/Describe/Announce/Record/SetupMedia (which all route through Do) with an RTSP URL whose credentials the camera/server rejects: the first request returns 401, credentials from the URL are applied (auth method is no longer AuthUnknown/AuthNone), and the retried request returns 401 again.

Common situations: Typo or stale password in an RTSP URL like rtsp://user:pass@camera/stream; camera credentials changed after a firmware update or password reset; special characters in the password not URL-encoded in the URL; account locked on the camera; using credentials from a different device.

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/034c191d7551d7f8. Report an issue: GitHub.

Appendix: source

Thrown at pkg/rtsp/client.go:136

		}

		req.URL = c.URL // because path was changed

		return c.Do(req)

	case http.StatusUnauthorized:
		switch c.auth.Method {
		case tcp.AuthNone:
			if c.auth.ReadNone(res) {
				return c.Do(req)
			}
			return nil, errors.New("user/pass not provided")
		case tcp.AuthUnknown:
			if c.auth.Read(res) {
				return c.Do(req)
			}
		default:
			return nil, errors.New("wrong user/pass")
		}
	}

	return res, fmt.Errorf("wrong response on %s", req.Method)
}

func (c *Conn) Options() error {
	req := &tcp.Request{Method: MethodOptions, URL: c.URL}

	res, err := c.Do(req)
	if err != nil {
		return err
	}

	if val := res.Header.Get("Content-Base"); val != "" {
		c.URL, err = urlParse(val)
		if err != nil {
			return err

View on GitHub (pinned to c245815e75)