You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to implement an ICE client that can find (for now) my local address and my public address using a TURN/STUN client. I am able to verify that I can find my public address using a UDP socket and stun_keepalive. However, when I try to implement an ICE client and add the UDP socket in, I am getting no UDP responses of any kind upon re_main().
// 1. Allocate the ICE session manager.
uint64_t tiebrk = rand_u64();
err = icem_alloc(&m_icem, ICE_ROLE_CONTROLLING, IPPROTO_UDP, 0,
tiebrk, "longufragthatislongen", "areallylongpasswordthatisdefinitelylongenough",
ice_conncheck_handler, this);
if (err) {
char errbuf[256];
str_error(err, errbuf, sizeof(errbuf));
ESP_LOGE(TAG, "icem_alloc failed: %s", errbuf);
} else {
ESP_LOGI(TAG, "icem_alloc success");
}
struct sa laddr;
sa_init(&laddr, AF_INET);
sa_set_str(&laddr, "0.0.0.0", 0);
// 2. Create our UDP socket.
struct udp_sock *stun_sock = NULL;
err = udp_listen(&stun_sock, &laddr, udp_recv_handler, NULL);
if (err) {
ESP_LOGE(TAG, "udp_listen for STUN failed: %d", err);
} else {
ESP_LOGI(TAG, "udp_listen for STUN success");
}
// 3. Add the RTP socket as a component. This discovers the "host" candidate.
err = icem_comp_add(m_icem, 1, stun_sock);
if (err) {
ESP_LOGE(TAG, "icem_comp_add (RTP) failed: %d", err);
} else {
ESP_LOGI(TAG, "icem_comp_add (RTP) success. Host candidate discovered.");
}
struct sa stun_server_addr;
sa_set_str(&stun_server_addr, "74.125.250.129", 19302); // stun.l.google.com, also 19302, 3478
// 4. Create a TURN/STUN client.
struct turnc *turn_client = NULL;
err = turnc_alloc(&turn_client, NULL, IPPROTO_UDP, stun_sock, 0,
&stun_server_addr, "", "", 0, turn_response_handler, this);
if (err) {
ESP_LOGE(TAG, "turnc_alloc failed: %d", err);
} else {
ESP_LOGI(TAG, "turnc_alloc success");
}
// 5. Associate the TURN client with the ICE component.
// This should trigger the STUN request to find our public IP.
err = icem_set_turn_client(m_icem, 1, turn_client);
if (err) {
ESP_LOGE(TAG, "icem_set_turn_client failed: %d", err);
} else {
ESP_LOGI(TAG, "icem_set_turn_client success. Discovering server-reflexive candidate...");
}
err = re_main(signal_handler);
This leads to a timeout upon calling re_main() after around 40 seconds. Is my implementation correct?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to implement an ICE client that can find (for now) my local address and my public address using a TURN/STUN client. I am able to verify that I can find my public address using a UDP socket and stun_keepalive. However, when I try to implement an ICE client and add the UDP socket in, I am getting no UDP responses of any kind upon re_main().
This leads to a timeout upon calling re_main() after around 40 seconds. Is my implementation correct?
Beta Was this translation helpful? Give feedback.
All reactions