You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Asterisk发起呼叫时遇TimeoutError [WinError 10060]问题求助

Troubleshooting Asterisk SIP Connection Timeout (WinError 10060)

Let's walk through fixing the connection timeout error you're hitting when trying to initiate a call with Asterisk. First, let's recap your setup to align on the context:

  • SIP Server Config: HOST = "182.156.197.37", PORT = 5060
  • Call Trigger: click_to_call(phone_to_dial='0119189788xxxxx', username='xxxxx', password="xxxxxx", local_user='600')
  • Error Point: Fails at s.connect((HOST, PORT)) with TimeoutError: [WinError 10060] 连接超时

Here are actionable steps to diagnose and resolve this:

1. Verify Basic Network Connectivity

Start with the simplest checks to rule out core network issues:

  • Run ping 182.156.197.37 in your Windows command prompt. If you get no responses or high packet loss, your machine can't reach the Asterisk server at all—this could stem from routing problems, ISP restrictions, or the server being offline.
  • Test port 5060 accessibility: Use PowerShell with Test-NetConnection 182.156.197.37 -Port 5060, or Command Prompt with telnet 182.156.197.37 5060. If this fails, the port is blocked by your local Windows firewall, the server's firewall, or an intermediate network device.

2. Check Asterisk Server's Port & Access Rules

Log into your Asterisk server and confirm:

  • The SIP service is actively listening on port 5060. On Linux, run netstat -an | grep 5060; on Windows, use netstat -ano | findstr :5060. You should see the port listed as "LISTENING".
  • Your client's IP address is allowed to connect. Check your sip.conf (or pjsip.conf if using PJSIP) for IP whitelists, allow directives, or account-specific access restrictions. Ensure your local machine's IP isn't blocked.

3. Validate Authentication & Account Setup

While this isn't the root cause of the timeout, it's worth confirming now to avoid post-connection issues:

  • Double-check that username, password, and local_user='600' exactly match the account configured on the Asterisk server. If the account doesn't exist or credentials are incorrect, you'll hit auth errors once the connection is fixed.
  • Note: The phone number format 0119189788xxxxx uses the US international access code (011)—if you're calling from a different region, you may need to adjust this later, but it's not causing the current timeout.

4. Rule Out Local Environment Restrictions

  • Temporarily disable your Windows Firewall to test if it's blocking outbound traffic to port 5060. If the connection works after disabling, add an exception for your Python script or port 5060.
  • If you're on a corporate network, there might be a proxy or NAT rule blocking SIP traffic. Try switching to a personal mobile hotspot to see if the connection works outside the corporate environment.

5. Confirm SIP Protocol Match

SIP typically uses UDP for port 5060, but some servers are configured to use TCP instead. Check if your client code is using the correct protocol—trying to make a TCP connection to a server only listening for UDP will result in a timeout.

内容的提问来源于stack exchange,提问作者Raady

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:31:28