{"record":{"id":"9404ff53358a2c22","repo":"m1k1o/neko","slug":"webrtc-data-channel-not-found","errorCode":null,"errorMessage":"webrtc data channel not found","messagePattern":"webrtc data channel not found","errorType":"error_code","errorClass":"ErrWebRTCDataChannelNotFound","httpStatus":null,"severity":"error","filePath":"server/pkg/types/webrtc.go","lineNumber":10,"sourceCode":"package types\n\nimport (\n\t\"errors\"\n\n\t\"github.com/pion/webrtc/v4\"\n)\n\nvar (\n\tErrWebRTCDataChannelNotFound = errors.New(\"webrtc data channel not found\")\n\tErrWebRTCConnectionNotFound  = errors.New(\"webrtc connection not found\")\n\tErrWebRTCStreamNotFound      = errors.New(\"webrtc stream not found\")\n)\n\ntype ICEServer struct {\n\tURLs       []string `mapstructure:\"urls\"       json:\"urls\"`\n\tUsername   string   `mapstructure:\"username\"   json:\"username,omitempty\"`\n\tCredential string   `mapstructure:\"credential\" json:\"credential,omitempty\"`\n}\n\ntype PeerVideo struct {\n\tDisabled bool   `json:\"disabled\"`\n\tID       string `json:\"id\"`\n\tVideo    string `json:\"video\"` // TODO: Remove this, used for compatibility with old clients.\n\tAuto     bool   `json:\"auto\"`\n}\n\ntype PeerVideoRequest struct {","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/pkg/types/webrtc.go#L1-L28","documentation":"ErrWebRTCDataChannelNotFound is a sentinel error in the neko types package indicating that a WebRTC peer lookup for its data channel failed — the expected data channel (e.g. for cursor/control messages) has not been created or has not been opened yet. Code returns it when it tries to use a peer's data channel that is nil or absent.","triggerScenarios":"Sending cursor position/cursor image over a peer whose data channel was never negotiated or not yet open; using a WebRTCPeer before the signaling/ICE handshake completes; after the data channel was closed by either side.","commonSituations":"Clients calling control APIs before the WebRTC connection finishes opening; ICE connection failures leaving the channel unestablished; browsers blocking WebRTC data channels (extensions, strict networks); peers destroyed mid-use.","solutions":["Ensure the WebRTC handshake (offer/answer, ICE) completed and the data channel is 'open' before sending messages.","Check the client logs/browser console for ICE connection failures and fix STUN/TURN (ICEServers) configuration.","Retry the send after the peer signals its data channel opened.","Destroy and recreate the peer if the channel is permanently closed.","Verify client and server neko versions are compatible (pion webrtc v4 negotiation)."],"exampleFix":"// before\nerr := peer.SendCursorPosition(x, y) // ErrWebRTCDataChannelNotFound if channel not open\n// after\nif peer.DataChannel() == nil || peer.DataChannel().ReadyState() != webrtc.DataChannelStateOpen {\n    return nil // or queue the message until the channel opens\n}\nerr := peer.SendCursorPosition(x, y)","handlingStrategy":"try-catch","validationCode":"// only send after the data channel is open\nif ch := peer.DataChannel(); ch == nil || ch.ReadyState() != webrtc.DataChannelStateOpen {\n    return errors.New(\"data channel not open yet\")\n}","typeGuard":"func DataChannelReady(p types.WebRTCPeer) bool {\n    ch := p.DataChannel()\n    return ch != nil && ch.ReadyState() == webrtc.DataChannelStateOpen\n}","tryCatchPattern":"if err := peer.SendCursorPosition(x, y); err != nil {\n    if errors.Is(err, types.ErrWebRTCDataChannelNotFound) {\n        // queue and resend once the channel opens\n        return\n    }\n    return err\n}","preventionTips":["Wait for onopen/onstatechange before sending messages.","Validate ICE/TURN configuration so connections complete.","Handle peer destroy events by dropping pending sends.","Keep client and server WebRTC library versions aligned."],"tags":["webrtc","data-channel","not-found","go"],"backgroundTag":"webrtc-data-channel-not-open","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}