go-ring API Reference
Guides

Live sessions

Open a signaling connection and manage a device session's lifetime.

A live session has two connections with different jobs:

  • Your WebRTC implementation owns the peer connection and sends or receives media.
  • SignalingConnection owns Ring's authenticated WebSocket. Its DeviceSession exchanges signaling messages and provides live session controls.

Create the signaling connection with the account you want to use, then start a device session with an SDP offer generated by your WebRTC peer. The library returns the answer after Ring has accepted and activated the session. Apply that answer to the same peer connection. See SDP and ICE for both candidate exchange modes.

conn, err := client.OpenSignaling(ctx, ring.OpenSignalingRequest{Auth: auth})
if err != nil {
	return err
}
defer conn.Close()

session, err := conn.StartDeviceSession(ctx, ring.StartDeviceSessionRequest{
	DeviceID: deviceID,
	Offer: ring.SessionDescription{
		Type: ring.SDPTypeOffer,
		SDP:  offerSDP,
	},
	VideoEnabled: true,
	ICEMode:      ring.ICENonTrickle,
})
if err != nil {
	return err
}
defer session.Close()

answer := session.Answer()
if err := peer.SetRemoteDescription(webrtc.SessionDescription{
	Type: webrtc.SDPTypeAnswer,
	SDP:  answer.SDP,
}); err != nil {
	return err
}

Use a context whose lifetime matches the work. Canceling the context used to open the signaling connection ends that connection and its child sessions. Close the device session when the call or stream ends, then close the signaling connection. The shared client can be reused and has no connection state to close. The library sends session heartbeats and handles signaling liveness internally; callers do not send ping or pong messages themselves.

The client enforces a maximum session age of 60 minutes. This is a library lifecycle limit, not a claim about Ring's server timeout. DeviceSession.State reports active, closed, expired, or failed state; Wait waits for termination.

On supported cameras, DeviceSession also exposes pan, tilt, microphone, and stream-option controls. Continuous movement should be followed by StopPTZ; an acknowledgement confirms the command response, not the camera's physical position. The client also stops tracked continuous movement when closing a session.

See examples/rtc_stream for a complete Pion example. It receives media packets but leaves rendering and media handling to the application.

Signaling contracts: start a live view, activate the session, change microphone state, change stream options, and close the session.