diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5994003b6f..4f4ebb929c 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9475,7 +9475,9 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char * /* Set transport and port so the correct contact is built */ p->socket.type = r->transport; - p->socket.port = htons(r->portno); + if (r->transport == SIP_TRANSPORT_TLS || r->transport == SIP_TRANSPORT_TCP) { + p->socket.port = sip_tcp_desc.sin.sin_port; + } /* check which address we should use in our contact header based on whether the remote host is on the external or