# Producer connection state stuck to "checking"

**URL:** <https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439>\
**Category:** mediasoup libraries\
**Created:** [July 15, 2020, 6:20pm UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439 "2020-07-15T18:20:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArcDexx](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/arcdexx/32/1040_2.png) [@ArcDexx](https://mediasoup.discourse.group/u/ArcDexx)\
**Post date:** [July 15, 2020, 6:20pm UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/1 "2020-07-15T18:20:28Z")

</div>

I am using the [mediasoup-client-android](https://github.com/haiyangwu/mediasoup-client-android) with [socket.io](http://socket.io). Here is my sendTransportListener :

```auto
val listener = object: SendTransport.Listener
 {
            override fun onConnect(transport: Transport?, dtlsParameters: String?)
            {
                val params = JSONObject()
                params.put("method", "connectWebRtcTransport")

                val data = JSONObject()
                data.put("transportId", sendTransport.id)
                data.put("dtlsParameters", dtlsParameters)

                params.put("data", data)

                socket.send("request", params)
            }

            override fun onProduce(transport: Transport?, kind: String?, rtpParameters: String?, appData: String?): String
            {
                val params = JSONObject()
                params.put("method", "produce")

                val data = JSONObject()
                data.put("transportId", sendTransport.id)
                data.put("kind", kind)
                data.put("rtpParameters", JSONObject(rtpParameters))
                data.put("appData", appData)

                params.put("data", data)

                val latch = CountDownLatch(1)

                socket.emit("request", params, Ack { args ->

                    val idObj = args.firstOrNull { arg -> arg is JSONObject } as JSONObject
                    sendTransportRemoteId = idObj.getString("id")

                    latch.countDown()
                })

                latch.await()

                Log.i("Socket", "Returning = $sendTransportRemoteId // Thread = ${Thread.currentThread().name} // State = ${transport?.connectionState}")

                return sendTransportRemoteId
            }

            override fun onConnectionStateChange(transport: Transport?, connectionState: String?) {
                Log.i("Socket", "Send Transport : ${transport.toString()}, connectionState : $connectionState")
            }
        }

```

---

<div class="post-metadata">

**Author:** ![ethand91](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ethand91/32/14_2.png) [@ethand91](https://mediasoup.discourse.group/u/ethand91)\
**Post date:** [July 16, 2020, 12:58am UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/2 "2020-07-16T00:58:56Z")

</div>

Does “latch.countDown” run?

---

<div class="post-metadata">

**Author:** ![ArcDexx](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/arcdexx/32/1040_2.png) [@ArcDexx](https://mediasoup.discourse.group/u/ArcDexx)\
**Post date:** [July 16, 2020, 7:56am UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/3 "2020-07-16T07:56:40Z")

</div>

Yes, the log shows the correct producerId is returned.

---

<div class="post-metadata">

**Author:** ![ethand91](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ethand91/32/14_2.png) [@ethand91](https://mediasoup.discourse.group/u/ethand91)\
**Post date:** [July 22, 2020, 9:41am UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/4 "2020-07-22T09:41:28Z")

</div>

I’m assuming the checking state is the SendTransport not the producer.  
Does it not change to failed after a while?  
Does anything interesting popup on the server side with mediasoup debug logs enabled?  
Have you set up the webrtc transport listen Ips on the server side to the correct ip?

---

<div class="post-metadata">

**Author:** ![ArcDexx](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/arcdexx/32/1040_2.png) [@ArcDexx](https://mediasoup.discourse.group/u/ArcDexx)\
**Post date:** [July 23, 2020, 2:04pm UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/5 "2020-07-23T14:04:31Z")

</div>

- You are correct, it is the SendTransport that is stuck in “checking” state.

- It does switch to “failed” after a while, although not in a predictable way.

- The logs are the same when I successfully connect with my browser implementation.

- No problem when connecting from browser, including mobile browser, so I would assume everything is properly set server wise.

Unrelated issue but it might help in resolving : I am also unable to consume anything as I never get the “newConsumer” events. It is odd since I do receive other events such as “newPeer” or “activeSpeaker”…

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [July 23, 2020, 4:10pm UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/6 "2020-07-23T16:10:07Z")

</div>

> override fun onConnect(transport: Transport?, dtlsParameters: String?)

`dtlsParameters` are not a `String` in [libmeidasoupclient](https://mediasoup.org/documentation/v3/mediasoup/api/#WebRtcTransportDtlsParameters)

On the other hand, you may need to trace the network traffic (tcpdump, wireshark, or alike) and check that the ICE binding requests are being sent to mediasoup and replied back.

---

<div class="post-metadata">

**Author:** ![tanaymondal](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/tanaymondal/32/579_2.png) [@tanaymondal](https://mediasoup.discourse.group/u/tanaymondal)\
**Post date:** [September 24, 2020, 12:04pm UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/7 "2020-09-24T12:04:08Z")

</div>

I am also not getting “newConsumer” events. How did you resolve it?

---

<div class="post-metadata">

**Author:** ![ArcDexx](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/arcdexx/32/1040_2.png) [@ArcDexx](https://mediasoup.discourse.group/u/ArcDexx)\
**Post date:** [June 11, 2021, 9:45am UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/8 "2021-06-11T09:45:37Z")

</div>

It was a JSON escaping issue, resulting in wrongly formatted `rtpCapabilities` being sent. After solving that I did receive the `newConsumer` events.

However, the same problem that I had originally is still there : for either `ReceiveTransport` or `SendTransport`, the `connectionState` will be stuck to `checking` even though server logs are showing successful ` transport.connect()` requests

@jmillan Can you please elaborate on the network traffic tracing ? What should I be looking for exactly ?

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [June 14, 2021, 8:16am UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/9 "2021-06-14T08:16:44Z")

</div>

> [@ArcDexx](#):
>
> `SendTransport` , the `connectionState` will be stuck to `checking` even though server logs are showing successful ` transport.connect()` requests

A `checking` state is indicating that the connection is looking for a usable candiate pair. Look for the ICE candidates you are providing to mediasoup and check if those IP/port make sense.

[https://w3c.github.io/webrtc-pc/#dom-rtcicetransportstate-checking](https://w3c.github.io/webrtc-pc/#dom-rtcicetransportstate-checking)

This issue is related to your environment and not to mediasoup libraries.

---

<div class="post-metadata">

**Author:** ![ArcDexx](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/arcdexx/32/1040_2.png) [@ArcDexx](https://mediasoup.discourse.group/u/ArcDexx)\
**Post date:** [June 14, 2021, 5:15pm UTC](https://mediasoup.discourse.group/t/producer-connection-state-stuck-to-checking/1439/11 "2021-06-14T17:15:52Z")

</div>

It turns out, the IP in the ICE candidates did NOT make sense after all ! I was able to fix it thanks to you. Thanks x1000000, you just made my week !
