Index: pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h	(revision 4037)
+++ pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h	(revision 4038)
@@ -266,4 +266,17 @@
 					      const pjsip_tpselector *sel);
 
+/**
+ * Release the reference to current transport being used by the regc, if any.
+ * The regc keeps the reference to the last transport being used in order
+ * to prevent it from being destroyed. In some situation however, such as
+ * when the transport is disconnected, it is necessary to instruct the
+ * regc to release this reference so that the transport can be destroyed.
+ * See https://trac.pjsip.org/repos/ticket/1481 for background info.
+ *
+ * @param regc	    The client registration instance.
+ *
+ * @return	    PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsip_regc_release_transport(pjsip_regc *regc);
 
 /**
Index: pjproject/trunk/pjsip/include/pjsip/sip_config.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsip/sip_config.h	(revision 4037)
+++ pjproject/trunk/pjsip/include/pjsip/sip_config.h	(revision 4038)
@@ -428,6 +428,7 @@
 
 /**
- * Idle timeout interval to be applied to transports with no usage
- * before the transport is destroyed. Value is in seconds.
+ * Idle timeout interval to be applied to outgoing transports (i.e. client
+ * side) with no usage before the transport is destroyed. Value is in
+ * seconds.
  *
  * Default: 30
@@ -435,4 +436,17 @@
 #ifndef PJSIP_TRANSPORT_IDLE_TIME
 #   define PJSIP_TRANSPORT_IDLE_TIME	30
+#endif
+
+
+/**
+ * Idle timeout interval to be applied to incoming transports (i.e. server
+ * side) with no usage before the transport is destroyed. Server typically
+ * should let client close the connection, hence set this interval to a large
+ * value. Value is in seconds.
+ *
+ * Default: 600
+ */
+#ifndef PJSIP_TRANSPORT_SERVER_IDLE_TIME
+#   define PJSIP_TRANSPORT_SERVER_IDLE_TIME	600
 #endif
 
Index: pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c	(revision 4037)
+++ pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c	(revision 4038)
@@ -441,4 +441,15 @@
 }
 
+/* Release transport */
+PJ_DEF(pj_status_t) pjsip_regc_release_transport(pjsip_regc *regc)
+{
+    PJ_ASSERT_RETURN(regc, PJ_EINVAL);
+    if (regc->last_transport) {
+	pjsip_transport_dec_ref(regc->last_transport);
+	regc->last_transport = NULL;
+    }
+    return PJ_SUCCESS;
+}
+
 
 PJ_DEF(pj_status_t) pjsip_regc_add_headers( pjsip_regc *regc,
@@ -1270,5 +1281,7 @@
 
     /* Get last transport used and add reference to it */
-    if (tdata->tp_info.transport != regc->last_transport) {
+    if (tdata->tp_info.transport != regc->last_transport &&
+	status==PJ_SUCCESS)
+    {
 	if (regc->last_transport) {
 	    pjsip_transport_dec_ref(regc->last_transport);
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport.c	(revision 4037)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport.c	(revision 4038)
@@ -858,5 +858,7 @@
 		delay.sec = delay.msec = 0;
 	    } else {
-		delay.sec = PJSIP_TRANSPORT_IDLE_TIME;
+		delay.sec = (tp->dir==PJSIP_TP_DIR_OUTGOING) ?
+				PJSIP_TRANSPORT_IDLE_TIME :
+				PJSIP_TRANSPORT_SERVER_IDLE_TIME;
 		delay.msec = 0;
 	    }
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 4037)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 4038)
@@ -2883,4 +2883,11 @@
 	}
 
+	/* Release regc transport immediately
+	 * See https://trac.pjsip.org/repos/ticket/1481
+	 */
+	if (pjsua_var.acc[i].regc) {
+	    pjsip_regc_release_transport(pjsua_var.acc[i].regc);
+	}
+
 	/* Schedule reregistration for this account */
 	schedule_reregistration(acc);
