{"record":{"id":"45e03c5c450c8f5e","repo":"AlexxIT/go2rtc","slug":"wrong-answer","errorCode":null,"errorMessage":"wrong answer: ","messagePattern":"wrong answer: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/webrtc/client.go","lineNumber":145,"sourceCode":"\t// 3. Create offer\n\toffer, err := prod.CreateOffer(medias)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// 4. Send offer\n\tmsg := &ws.Message{Type: \"webrtc/offer\", Value: offer}\n\tconnMu.Lock()\n\t_ = conn.WriteJSON(msg)\n\tconnMu.Unlock()\n\n\t// 5. Get answer\n\tif err = conn.ReadJSON(msg); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif msg.Type != \"webrtc/answer\" {\n\t\terr = errors.New(\"wrong answer: \" + msg.String())\n\t\treturn nil, err\n\t}\n\n\tanswer := msg.String()\n\tif err = prod.SetAnswer(answer); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// 6. Continue to receiving candidates\n\tgo func() {\n\t\tvar err error\n\n\t\tfor {\n\t\t\t// receive data from remote\n\t\t\tvar msg ws.Message\n\t\t\tif err = conn.ReadJSON(&msg); err != nil {\n\t\t\t\tbreak\n\t\t\t}","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/webrtc/client.go#L127-L163","documentation":"go2rtcClient expects the first JSON message on the go2rtc WS signaling channel to have type \"webrtc/answer\"; anything else (typically \"webrtc/error\") aborts with this error including the message payload.","triggerScenarios":"Connecting to a go2rtc server where the src name is unknown/invalid, the source stream is not running, or the server sends an error response instead of the SDP answer.","commonSituations":"Stream name typo in the ws URL (?src=name); the target stream isn't defined or failed to start on the remote go2rtc; pointing at a non-go2rtc WS endpoint that replies with a different protocol message.","solutions":["Check the exact msg content after \"wrong answer: \" — if it says the source is not found, fix the src name","Verify the stream exists and is online on the remote go2rtc instance (check its web UI/API)","Ensure the WS endpoint is actually a go2rtc /api/ws signaling endpoint, not another service","Test the same src with a simpler consumer (e.g. HLS) to confirm the source works"],"exampleFix":"// before\nconst ws = new WebSocket(\"ws://host:1984/api/ws?src=camra1\");\n// after\nconst ws = new WebSocket(\"ws://host:1984/api/ws?src=camera1\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"prod, err := go2rtcClient(url)\nif err != nil && strings.HasPrefix(err.Error(), \"wrong answer: \") {\n\tlog.Printf(\"go2rtc signaling rejected: %s\", strings.TrimPrefix(err.Error(), \"wrong answer: \"))\n\t// verify src exists on remote go2rtc before reconnecting\n}","preventionTips":["Verify stream names exist on the remote go2rtc (query /api/streams)","Confirm the WS endpoint is /api/ws on a go2rtc server","Pre-check source availability with a simpler consumer before WebRTC"],"tags":["go","webrtc","websocket","signaling"],"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-16T04:17:20.429Z"}