|
38 | 38 | from .access_token import VideoGrants, SIPGrants |
39 | 39 |
|
40 | 40 | SVC = "SIP" |
| 41 | + |
| 42 | +# Calls that dial a phone (CreateSIPParticipant with wait_until_answered, |
| 43 | +# TransferSIPParticipant) take longer than a normal request. |
| 44 | +SIP_DIAL_TIMEOUT = 30.0 |
41 | 45 | """@private""" |
42 | 46 |
|
43 | 47 |
|
@@ -782,16 +786,12 @@ async def create_sip_participant( |
782 | 786 | """ |
783 | 787 | client_timeout: Optional[aiohttp.ClientTimeout] = None |
784 | 788 | if timeout: |
785 | | - # obay user specified timeout |
| 789 | + # obey user specified timeout |
786 | 790 | client_timeout = aiohttp.ClientTimeout(total=timeout) |
787 | 791 | elif create.wait_until_answered: |
788 | | - # ensure default timeout isn't too short when using sync mode |
789 | | - if ( |
790 | | - self._client._session.timeout |
791 | | - and self._client._session.timeout.total |
792 | | - and self._client._session.timeout.total < 20 |
793 | | - ): |
794 | | - client_timeout = aiohttp.ClientTimeout(total=20) |
| 792 | + # Dialing a phone and waiting for an answer takes longer than a |
| 793 | + # normal call, so use a longer default. |
| 794 | + client_timeout = aiohttp.ClientTimeout(total=SIP_DIAL_TIMEOUT) |
795 | 795 |
|
796 | 796 | if trunk_id: |
797 | 797 | create.sip_trunk_id = trunk_id |
@@ -831,6 +831,8 @@ async def transfer_sip_participant( |
831 | 831 | sip=SIPGrants(call=True), |
832 | 832 | ), |
833 | 833 | SIPParticipantInfo, |
| 834 | + # Transferring a call dials a phone, which takes longer than normal. |
| 835 | + timeout=aiohttp.ClientTimeout(total=SIP_DIAL_TIMEOUT), |
834 | 836 | ) |
835 | 837 |
|
836 | 838 | def _admin_headers(self) -> dict[str, str]: |
|
0 commit comments