paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.73k stars 353 forks source link

How to troubleshoot when the onGatheringStateChange function returns very slowly? #1234

Open bestxpp opened 1 month ago

bestxpp commented 1 month ago
        pc_->onGatheringStateChange([this, pc = pc_](rtc::PeerConnection::GatheringState state) {
            std::ostringstream oss;
            oss << state;
            LOG_INFO("Gathering State: {}", oss.str());

            if (state == rtc::PeerConnection::GatheringState::Complete) {
                auto           description = pc->localDescription();
                nlohmann::json message     = {{"type", description->typeString()}, {"sdp", std::string(description.value())}};
                // std::cout << message << std::endl;
                nlohmann::json sendOffer = {{"type:", wb_type::offer}, {"data", message.dump()}};
                LOG_INFO("send: {}", sendOffer.dump());
                MyWebSocket::get().send(sendOffer.dump());
            }
        });

the onGatheringStateChange function returns very slowly,It takes 20 to even 40 seconds to gather ICE information. coturn and my application are running on the same host; the difference is that my application is running in a Docker container, while coturn is running on the host machine

paullouisageneau commented 1 month ago

It means one of your ICE servers is not reachable, so gathering done is only triggered after it times out.