Index: pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 1134)
+++ pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 1135)
@@ -1318,44 +1318,5 @@
 static void app_dump(pj_bool_t detail)
 {
-    unsigned old_decor;
-    char buf[1024];
-
-    PJ_LOG(3,(THIS_FILE, "Start dumping application states:"));
-
-    old_decor = pj_log_get_decor();
-    pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
-
-    if (detail)
-	pj_dump_config();
-
-    pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail);
-    pjmedia_endpt_dump(pjsua_get_pjmedia_endpt());
-    pjsip_tsx_layer_dump(detail);
-    pjsip_ua_dump(detail);
-
-
-    /* Dump all invite sessions: */
-    PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:"));
-
-    if (pjsua_call_get_count() == 0) {
-
-	PJ_LOG(3,(THIS_FILE, "  - no sessions -"));
-
-    } else {
-	unsigned i;
-
-	for (i=0; i<app_config.cfg.max_calls; ++i) {
-	    if (pjsua_call_is_active(i)) {
-		pjsua_call_dump(i, detail, buf, sizeof(buf), "  ");
-		PJ_LOG(3,(THIS_FILE, "%s", buf));
-	    }
-	}
-    }
-
-    /* Dump presence status */
-    pjsua_pres_dump(detail);
-
-    pj_log_set_decor(old_decor);
-    PJ_LOG(3,(THIS_FILE, "Dump complete"));
+    pjsua_dump(detail);
 }
 
Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 1134)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 1135)
@@ -1328,5 +1328,12 @@
 
 
-
+/**
+ * This is a utility function to dump the stack states to log, using
+ * verbosity level 3.
+ *
+ * @param detail	Will print detailed output (such as list of
+ *			SIP transactions) when non-zero.
+ */
+PJ_DECL(void) pjsua_dump(pj_bool_t detail);
 
 /**
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1134)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1135)
@@ -744,4 +744,5 @@
 	if (pjsua_var.ua_cfg.stun_domain.slen) {
 	    pj_str_t res_type;
+	    pj_status_t status;
 
 	    /* Fail if resolver is not configured */
@@ -753,12 +754,15 @@
 	    }
 	    res_type = pj_str("_stun._udp");
-	    pjsua_var.stun_status = 
+	    status = 
 		pj_dns_srv_resolve(&pjsua_var.ua_cfg.stun_domain, &res_type,
 				   3478, pjsua_var.pool, pjsua_var.resolver,
-				   0, NULL, stun_dns_srv_resolver_cb);
-	    if (pjsua_var.stun_status != PJ_SUCCESS) {
+				   0, NULL, &stun_dns_srv_resolver_cb);
+	    if (status != PJ_SUCCESS) {
 		pjsua_perror(THIS_FILE, "Error starting DNS SRV resolution", 
 			     pjsua_var.stun_status);
+		pjsua_var.stun_status = status;
 		return pjsua_var.stun_status;
+	    } else {
+		pjsua_var.stun_status = PJ_EPENDING;
 	    }
 	}
@@ -1691,2 +1695,68 @@
     return p ? 0 : -1;
 }
+
+
+/*
+ * This is a utility function to dump the stack states to log, using
+ * verbosity level 3.
+ */
+PJ_DEF(void) pjsua_dump(pj_bool_t detail)
+{
+    unsigned old_decor;
+    unsigned i;
+    char buf[1024];
+
+    PJ_LOG(3,(THIS_FILE, "Start dumping application states:"));
+
+    old_decor = pj_log_get_decor();
+    pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
+
+    if (detail)
+	pj_dump_config();
+
+    pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail);
+
+    pjmedia_endpt_dump(pjsua_get_pjmedia_endpt());
+
+    PJ_LOG(3,(THIS_FILE, "Dumping media transports:"));
+    for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) {
+	pjsua_call *call = &pjsua_var.calls[i];
+	pjmedia_sock_info skinfo;
+
+	pjmedia_transport_get_info(call->med_tp, &skinfo);
+
+	PJ_LOG(3,(THIS_FILE, " %s: %s:%d",
+		  (pjsua_var.media_cfg.enable_ice ? "ICE" : "UDP"),
+		  pj_inet_ntoa(skinfo.rtp_addr_name.sin_addr),
+		  (int)pj_ntohs(skinfo.rtp_addr_name.sin_port)));
+    }
+
+    pjsip_tsx_layer_dump(detail);
+    pjsip_ua_dump(detail);
+
+
+    /* Dump all invite sessions: */
+    PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:"));
+
+    if (pjsua_call_get_count() == 0) {
+
+	PJ_LOG(3,(THIS_FILE, "  - no sessions -"));
+
+    } else {
+	unsigned i;
+
+	for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) {
+	    if (pjsua_call_is_active(i)) {
+		pjsua_call_dump(i, detail, buf, sizeof(buf), "  ");
+		PJ_LOG(3,(THIS_FILE, "%s", buf));
+	    }
+	}
+    }
+
+    /* Dump presence status */
+    pjsua_pres_dump(detail);
+
+    pj_log_set_decor(old_decor);
+    PJ_LOG(3,(THIS_FILE, "Dump complete"));
+}
+
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1134)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1135)
@@ -557,4 +557,11 @@
     pj_sockaddr_in addr;
     pj_status_t status;
+
+    /* Make sure STUN server resolution has completed */
+    status = pjsua_resolve_stun_server(PJ_TRUE);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Error resolving STUN server", status);
+	return status;
+    }
 
     pj_sockaddr_in_init(&addr, 0, (pj_uint16_t)cfg->port);
