I analyze that when Web phone connects asterisk , asterisk sends SIP/2.0 401 Unauthorized. Following are registration logs
== WebSocket connection from ‘182.176.118.54:20867’ for protocol ‘sip’ accepted using version ‘13’
<— Received SIP request (524 bytes) from WSS:182.176.118.54:20867 —>
REGISTER sip:110.20.5.38 SIP/2.0
Via: SIP/2.0/WSS bdv55j4mqhm4.invalid;branch=z9hG4bK3347700
Max-Forwards: 70
To: sip:6004@110.20.5.38
From: sip:6004@110.20.5.38;tag=rkq5auhf4i
Call-ID: 22ung1uid9fnmpop1c0db2
CSeq: 6100 REGISTER
Contact: sip:7dinjgif@bdv55j4mqhm4.invalid;transport=ws;reg-id=1;+sip.instance=“urn:uuid:07aaf250-07e0-46ce-8a43-04971df57d1d”;expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, outbound
User-Agent: WebPhone/0.1.2
Content-Length: 0
<— Transmitting SIP response (464 bytes) to WSS:182.176.118.54:20867 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS bdv55j4mqhm4.invalid;rport=20867;received=182.176.118.54;branch=z9hG4bK3347700
Call-ID: 22ung1uid9fnmpop1c0db2
From: sip:6004@110.20.5.38;tag=rkq5auhf4i
To: sip:6004@110.20.5.38;tag=z9hG4bK3347700
CSeq: 6100 REGISTER
WWW-Authenticate: Digest realm=“asterisk”,nonce=“1543950476/ceadd44345aa6bb0a476478e968726e9”,opaque=“3b5fec582ce0f5aa”,algorithm=md5,qop=“auth”
Server: Asterisk PBX 13.22.0
Content-Length: 0
<— Received SIP request (788 bytes) from WSS:182.176.118.54:20867 —>
REGISTER sip:110.20.5.38 SIP/2.0
Via: SIP/2.0/WSS bdv55j4mqhm4.invalid;branch=z9hG4bK8640275
Max-Forwards: 70
To: sip:6004@110.20.5.38
From: sip:6004@110.20.5.38;tag=rkq5auhf4i
Call-ID: 22ung1uid9fnmpop1c0db2
CSeq: 6101 REGISTER
Authorization: Digest algorithm=MD5, username=“6004”, realm=“asterisk”, nonce=“1543950476/ceadd44345aa6bb0a476478e968726e9”, uri=“sip:110.20.5.38”, response=“8d87b110e5779116538ccbb8d4f12a29”, opaque=“3b5fec582ce0f5aa”, qop=auth, cnonce=“u9ibbvmt9kt9”, nc=00000001
Contact: sip:7dinjgif@bdv55j4mqhm4.invalid;transport=ws;reg-id=1;+sip.instance=“urn:uuid:07aaf250-07e0-46ce-8a43-04971df57d1d”;expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, outbound
User-Agent: WebPhone/0.1.2
Content-Length: 0
-- Added contact 'sip:7dinjgif@182.176.118.54:20867;transport=ws' to AOR '6004' with expiration of 600 seconds
-- Contact 6004/sip:7dinjgif@182.176.118.54:20867;transport=ws is now Unknown.
== Endpoint 6004 is now Reachable
Also following are call logs
== Setting global variable ‘SIPDOMAIN’ to ‘110.20.5.38’
– Executing [6004@supervisor:1] Answer(“PJSIP/6002-0000003b”, “”) in new stack
> 0x7f75d4029390 – Strict RTP learning after remote address set to: 182.176.118.54:4000
> 0x7f75d4029390 – Strict RTP switching to RTP target address 182.176.118.54:4000 as source
– Executing [6004@supervisor:2] NoCDR(“PJSIP/6002-0000003b”, “”) in new stack
[2018-12-04 20:17:21] WARNING[16230][C-0000001d]: func_channel.c:460 func_channel_read: Unknown or unavailable item requested: ‘uri’
– Executing [6004@supervisor:3] Set(“PJSIP/6002-0000003b”, “uri=”) in new stack
– Executing [6004@supervisor:4] Verbose(“PJSIP/6002-0000003b”, “3,Unknown call from to 6004”) in new stack
– Unknown call from to 6004
– Executing [6004@supervisor:5] Dial(“PJSIP/6002-0000003b”, “PJSIP/6004”) in new stack
– Called PJSIP/6004
– PJSIP/6002-0000003b requested media update control 26, passing it to PJSIP/6004-0000003c
== DTLS ECDH initialized (automatic), faster PFS enabled
– PJSIP/6004-0000003c is ringing
– PJSIP/6004-0000003c is ringing
> 0x7f75d4029390 – Strict RTP learning complete - Locking on source address 182.176.118.54:4000
– No one is available to answer at this time (1:0/0/0)
– Executing [6004@supervisor:6] Hangup(“PJSIP/6002-0000003b”, “”) in new stack