# Reconnect after transport connectionstate = failed

**URL:** <https://mediasoup.discourse.group/t/reconnect-after-transport-connectionstate-failed/5084>\
**Category:** mediasoup libraries\
**Created:** [March 24, 2023, 2:11pm UTC](https://mediasoup.discourse.group/t/reconnect-after-transport-connectionstate-failed/5084 "2023-03-24T14:11:51Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![zaidiqbal](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/zaidiqbal/32/1498_2.png) [@zaidiqbal](https://mediasoup.discourse.group/u/zaidiqbal)\
**Post date:** [March 24, 2023, 7:07pm UTC](https://mediasoup.discourse.group/t/reconnect-after-transport-connectionstate-failed/5084/5 "2023-03-24T19:07:26Z")

</div>

> [@techtruth](#):
>
> Conducting a server-side then client-side re-ice will ‘fix’ the connection, but its better to understand the underlying issue than to skip it with re-ice.

To understand the underlying issue, you will have to dig into server logs to see what is happening but most of the time if transport is getting failed it is because of the network conditions.

And if this is because of network conditions then the only thing you need to do is ‘restartIce’ like after every 10 seconds and when ‘connectionstatechange’ event tells you that it is connected then stop that restartIce process.

This is all so listen for this ‘connectionstatechange’ event, as mentioned by ibc, it should go to ‘connected’ state after successful restartIce:

> **[mediasoup :: API](https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-on-connectionstatechange)**
>
> Cutting Edge WebRTC Video Conferencing

One example is here:

> [@Transport connectionstate never changes to 'failed', stuck on 'disconnected'](https://mediasoup.discourse.group/t/transport-connectionstate-never-changes-to-failed-stuck-on-disconnected/4125/5):
>
> Here’s an example: transport.appData.idletimer = setTimeout(async (wss, room, handle) =\> { console.log("User had disconnected before transport connected. Alert them to request again."); if (Transports.has(room)) { Transports.get(room).delete(handle); if (Transports.get(room).size == 0) Transports.delete(room); } await transport.close(); wss.send(JSON.stringify({ …

---

_[View the full topic](https://mediasoup.discourse.group/t/reconnect-after-transport-connectionstate-failed/5084)._
