# The right way to performing ICE Restart in a VideoRoom Publisher

**URL:** <https://janus.discourse.group/t/the-right-way-to-performing-ice-restart-in-a-videoroom-publisher/921>\
**Category:** General\
**Created:** [March 12, 2024, 7:20pm UTC](https://janus.discourse.group/t/the-right-way-to-performing-ice-restart-in-a-videoroom-publisher/921 "2024-03-12T19:20:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![barakp](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@barakp](https://janus.discourse.group/u/barakp)\
**Post date:** [March 12, 2024, 7:20pm UTC](https://janus.discourse.group/t/the-right-way-to-performing-ice-restart-in-a-videoroom-publisher/921/1 "2024-03-12T19:20:42Z")

</div>

Hello,

I have implemented failure handling logic for WebRTC sessions on the publisher side in a videoroom. In my JavaScript client, when the `iceconnectionstatechange` event triggers with the state “failed”, I create a new offer with `iceRestart: true`, set the local description with this new offer, and then send a “configure” command to Janus with `“refresh”: true. After receiving the answer, I set the remote description.

From the Janus logs, I can see that the ICE agent restarts:

- Log entries showing ICE agent creation, warnings about audio mode, and ICE failure messages.
- Entries about closing video and audio recordings.
- More log entries about ICE agent creation, warnings, and negotiation updates indicating an ICE restart.

However, I’m confused about how the ICE restart process works with Janus. According to the documentation, I should send `"refresh": true` ([First experiments with ICE restarts by lminiero · Pull Request #753 · meetecho/janus-gateway · GitHub](https://github.com/meetecho/janus-gateway/pull/753)), but in the Janus code, it seems that `"restart": true` is expected. I tried sending “restart” and observed the same result.

When I send the “configure” command again without “refresh” or “restart”, I get the same result. It appears that Janus recognizes that negotiation has already occurred and performs an ICE restart automatically.

Could you please clarify the correct way to trigger an ICE restart with Janus?

---

<div class="post-metadata">

**Author:** ![barakp](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@barakp](https://janus.discourse.group/u/barakp)\
**Post date:** [March 12, 2024, 7:22pm UTC](https://janus.discourse.group/t/the-right-way-to-performing-ice-restart-in-a-videoroom-publisher/921/2 "2024-03-12T19:22:26Z")

</div>

This is Janus logs:  
[1954854557672680] Creating ICE agent (ICE Full mode, controlled)  
janus-1\_1 | [WARN] Audio offered as ‘recvonly’, but we need ‘recvonly’ for us: using ‘inactive’  
janus-1\_1 | [WARN] [1954854557672680] ICE failed for component 1 in stream 1, but let’s give it some time… (trickle received, answer received, alert not set)  
janus-1\_1 | [ERR] [ice.c:janus\_ice\_check\_failed:2066] [1954854557672680] ICE failed for component 1 in stream 1…  
janus-1\_1 | [janus.plugin.videoroom-0x7f6663050680] No WebRTC media anymore; 0x7f6664260500 0x7f6664264180  
janus-1\_1 | File is 8 bytes: 2024-03-12T18-10-34.356Z-video-0.mjr  
janus-1\_1 | Closed video recording 2024-03-12T18-10-34.356Z-video-0.mjr  
janus-1\_1 | File is 8 bytes: 2024-03-12T18-10-34.356Z-audio-1.mjr  
janus-1\_1 | Closed audio recording 2024-03-12T18-10-34.356Z-audio-1.mjr  
janus-1\_1 | [1954854557672680] WebRTC resources freed; 0x7f6664260500 0x7f66642640c0  
janus-1\_1 | [1954854557672680] Creating ICE agent (ICE Full mode, controlled)  
janus-1\_1 | [WARN] Audio offered as ‘recvonly’, but we need ‘recvonly’ for us: using ‘inactive’  
janus-1\_1 | [ERR] [ice.c:janus\_ice\_setup\_remote\_candidates:3519] [1954854557672680] No remote candidates for component 1 in stream 1: was the remote SDP parsed?  
janus-1\_1 | [1954854557672680] Negotiation update, checking what changed…  
janus-1\_1 | [1954854557672680] ICE restart detected  
janus-1\_1 | [1954854557672680] Restarting ICE…  
janus-1\_1 | [WARN] Audio offered as ‘recvonly’, but we need ‘recvonly’ for us: using ‘inactive’  
janus-1\_1 | [1954854557672680] Negotiation update, checking what changed…  
janus-1\_1 | [1954854557672680] ICE restart detected  
janus-1\_1 | [1954854557672680] Restarting ICE…  
janus-1\_1 | [WARN] Audio offered as ‘recvonly’, but we need ‘recvonly’ for us: using ‘inactive’  
janus-1\_1 | [1954854557672680] Negotiation update, checking what changed…  
janus-1\_1 | [1954854557672680] ICE restart detected  
janus-1\_1 | [1954854557672680] Restarting ICE…  
janus-1\_1 | [WARN] Audio offered as ‘recvonly’, but we need ‘recvonly’ for us: using ‘inactive’  
janus-1\_1 | [WARN] [1954854557672680] Failed to add some remote candidates (added 0, expected 1)  
janus-1\_1 | [1954854557672680] The DTLS handshake has been completed  
janus-1\_1 | [janus.plugin.videoroom-0x7f6663050680] WebRTC media is now available

---

<div class="post-metadata">

**Author:** ![lorenzo](https://yyz2.discourse-cdn.com/free1/user_avatar/janus.discourse.group/lorenzo/32/425_2.png) [@lorenzo](https://janus.discourse.group/u/lorenzo)\
**Post date:** [March 14, 2024, 10:56pm UTC](https://janus.discourse.group/t/the-right-way-to-performing-ice-restart-in-a-videoroom-publisher/921/3 "2024-03-14T22:56:47Z")

</div>

> [@barakp](#):
>
> Could you please clarify the correct way to trigger an ICE restart with Janus?

Depends on the role. For publishers, you need to have the client generate an offer with an ICE restart (which is what the `iceRestart: true` passed to `createOffer` will do, if you use `janus.js`) and send that updated offer to the VideoRoom. The Janus core will recognize the restart from the new ICE credentials; the VideoRoom itself won’t care, so even just a `configure` will suffice, no need for other stuff. For subscibers, it’s the VideoRoom that must trigger an ICE restart, and so there you do need to pass a custom flag (can’t remember which one, the docs will tell you).
