### Description
Following this scenario:
Softphone <-> Kamailio <-> Asterisk
1- Softphone registers with kamailio (REGISTER)
2- Kamailio challenges... (401)
3- Softphone registers with kamailio (REGISTER + Auth info)
4- Kamailio accepts (200)
5- If Kamailio accepted, it sends a REGISTER to asterisk (REGISTER)
6- Asterisk challenges... (401)
7- Kamailio authenticates (REGISTER + Auth info)
8- Asterisk accepts (200)
(NOTE: I know you can avoid Asterisk re-requesting for authentication, but in this case
it's mandatory.)
kamailio.cfg has this:
```
$var(rip) = $(avp(s:dsp_uri_list){uri.host});
$var(rip_port) = $(avp(s:dsp_uri_list){uri.port});
$uac_req(method)="REGISTER";
$uac_req(auser)=$avp(customer_user);
$uac_req(apasswd)=$avp(customer_pass);
$uac_req(ruri)="sip:" + $var(rip) + ":" + $var(rip_port);
$uac_req(furi)="sip:" + $au + "@" + $var(rip);
$uac_req(turi)="sip:" + $au + "@" + $var(rip);
$uac_req(hdrs)="Contact: <sip:" + $au +
"@X.X.X.X:5060>\r\n";
$uac_req(evroute)=1;
if ($sel(contact.expires) != $null) {
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires)
+ "\r\n";
} else {
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) +
"\r\n";
}
uac_req_send();
```
and this:
```
# Log replies from uac_req_send()
event_route[uac:reply] {
xlog("L_NOTICE", "[UAC] - $uac_req(method) request from user
$uac_req(auser) to $uac_req(ruri) completed with code: $uac_req(evcode)\n");
}
```
The result:
![image](https://user-images.githubusercontent.com/16212586/43027222-0a32bd48-8c2e-11e8-8038-16d0dba00dec.png)
```
Jul 20 16:49:42 sbc01 sbc[5236]: NOTICE: <script>: [UAC] - REGISTER request from
user XXXXX to sip:A.B.C.D:5060 completed with code: 401
Jul 20 16:51:05 sbc01 sbc[5240]: NOTICE: <script>: [UAC] - REGISTER request from
user XXXXX to sip:A.B.C.D:5060 completed with code: 401
Jul 20 16:51:49 sbc01 sbc[5241]: NOTICE: <script>: [UAC] - REGISTER request from
user XXXXX to sip:A.B.C.D:5060 completed with code: 401
Jul 20 17:00:06 sbc01 sbc[5239]: NOTICE: <script>: [UAC] - REGISTER request from
user XXXXX to sip:A.B.C.D:5060 completed with code: 401
Jul 20 17:09:06 sbc01 sbc[5240]: NOTICE: <script>: [UAC] - REGISTER request from
user XXXXX to sip:A.B.C.D:5060 completed with code: 401
```
I was expecting for `$uac_req(evcode)` to be 200, but it's 401.
#### Reproduction
Generate a REGISTER using uaq_send_req() with `auser` and `apasswd` set, and then print
the `$uac_req(evcode)` from the corresponding `event_route[]`.
### Possible Solutions
Not sure if the 401 is expected because it was the *first* final response, period.
Or, (when using authentication), it should be updated to 200 or whatever the reply is
after sending the REGISTER with auth info.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
# kamailio -v
version: kamailio 5.1.4 (x86_64/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST,
DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC,
DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER,
USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024,
BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 6.3.0
```
* **Operating System**:
```
OS: Debian stretch 9.4
Kernel: Linux kamailio 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
GNU/Linux
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1598