- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
'你好
我尝试使用 MJSIP 为 android 开发软电话。我有一个简单的测试设置:
sip phone #1000 可以调用#1001 和backwords。在 VM 上,我正在运行 eclipse,我尝试在 Freeswitch 上注册 android siphone(编号 1002)。但是我总是得到onUaRegistrationFailure
public class MainActivity extends Activity {
private static final String TAG = "Mjsip-Test-App|| ";
private IpAddress ip;
private int port = 5060;
int audioport = 3000;
private String password = "1234";
private String username = "1002";
private String realm = "172.22.0.34";
String fromUrl = "<sip:" + username + "@" + realm + ":" + port+">"; // FROM
String toUrl = "<sip:" + "1000@" + realm + ":" + port+">"; // TO
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.v(TAG, "Start");
if(!SipStack.isInit()){
SipStack.init();
Log.v(TAG, "Stack.init");
}
ip = IpAddress.getLocalHostAddress();
SipProvider sipProvider = new SipProvider(ip.toString(), port);
Log.v(TAG, "IP: " + ip.toString() + " port: " + port);
Log.v(TAG, "new sipProvider created");
UserAgentProfile profile = new UserAgentProfile();
profile.audio = true;// using audio
profile.audio_port = audioport;
profile.passwd = password;
profile.username = username;
profile.realm = realm;
Log.v(TAG, "new profile");
RegisterAgent reg = new RegisterAgent(sipProvider, toUrl, fromUrl,
username, realm, password, new RegisterAgentListener() {
@Override
public void onUaRegistrationSuccess(RegisterAgent ra,
NameAddress target, NameAddress contact,
String result) {
Log.v(TAG, "Listener: onUaRegistrationSuccess");
}
@Override
public void onUaRegistrationFailure(RegisterAgent ra,
NameAddress target, NameAddress contact,
String result) {
Log.v(TAG, "Listener: onUaRegistrationFailure");
}
});
reg.register();
Log.v(TAG, "reg.register()");
我的日志显示:
06-13 13:08:04.390: V/Mjsip-Test-App||(772): Start
06-13 13:08:04.409: V/Mjsip-Test-App||(772): Stack.init
06-13 13:08:04.539: V/Mjsip-Test-App||(772): IP: 127.0.0.1 port: 5060
06-13 13:08:04.539: V/Mjsip-Test-App||(772): new sipProvider created
06-13 13:08:04.539: V/Mjsip-Test-App||(772): new profile
06-13 13:08:04.989: V/Mjsip-Test-App||(772): reg.register()
06-13 13:08:05.399: I/ActivityManager(59): Displayed activity com.example.mjsipstacktest/.MainActivity: 2159 ms (total 2159 ms)
06-13 13:08:05.649: V/Mjsip-Test-App||(772): Listener: onUaRegistrationFailure
有人可以提示我如何注册 android 模拟器吗?为什么我会收到 UaRegistrationFailure?
谢谢
edit1:我更改了一些小东西,再次测试并查看 wireshark。
来自wireshark:400请求:
REGISTER sip:172.22.0.33:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK11085
Max-Forwards: 70
To: <sip:1000@172.22.0.33:5060>
From: <sip:1000@172.22.0.33:5060>;tag=z9hG4bK15659795
Call-ID: 522184753761@127.0.0.1
CSeq: 1 REGISTER
Contact: <sip:1002@172.22.0.33:5060>
Expires: 3600
User-Agent: mjsip stack 1.6
Content-Length: 0
编辑2:将端口编辑为“54321”并将 IP 编辑为 10.0.2.15 后,这应该是模拟器网络接口(interface) as written on the android dev page wireshark 显示 405(方法不允许)。
跟踪:
REGISTER sip:172.22.0.33:54321 SIP/2.0
Via: SIP/2.0/UDP 10.0.2.15:54321;rport;branch=z9hG4bK49856
Max-Forwards: 70
To: <sip:1000@172.22.0.33:54321>
From: <sip:1000@172.22.0.33:54321>;tag=z9hG4bK23560417
Call-ID: 241065424059@10.0.2.15
CSeq: 1 REGISTER
Contact: <sip:1002@172.22.0.33:54321>
Expires: 3600
User-Agent: mjsip stack 1.6
Content-Length: 0
编辑3:领域“172.22.0.34”端口 5060 和自己的 ip:10.0.2.15 显示结果:403 Forbidden 但我在 wireshark 中看不到任何内容。所以模拟器没有发送任何东西?
编辑4:我使用了不同的 IP 和端口配置。这是我测试过的。配置:
private String ip = "10.0.2.15";
private int port = 5060;
int audioport = 3000;
private String password = "1234";
private String username = "1001";
private String realm = "172.22.0.34";
String fromUrl = "<sip:" + username + "@" + realm + ":" + port + ">"; // FROM
String toUrl = "<sip:" + "1001@" + realm + ":" + port + ">"; // TO
Result 403 Forbidden
---> Wireshark is empty
更改端口
private String ip = "10.0.2.15";
private int port = 5554;
int audioport = 3000;
private String password = "1234";
private String username = "1001";
private String realm = "172.22.0.34";
String fromUrl = "<sip:" + username + "@" + realm + ":" + port + ">"; // FROM
String toUrl = "<sip:" + "1001@" + realm + ":" + port + ">"; // TO
06-18 08:42:52.617: V/Mjsip-Test-App||(2108): Result: Timeout
06-18 08:42:52.927: I/System.out(2108): UA: NOT FOUND/TIMEOUT
---> Wireshark is empty
修改realm的ip
private String ip = "10.0.2.15";
private int port = 5554;
int audioport = 3000;
private String password = "1234";
private String username = "1001";
private String realm = "172.22.0.31";
String fromUrl = "<sip:" + username + "@" + realm + ":" + port + ">"; // FROM
String toUrl = "<sip:" + "1001@" + realm + ":" + port + ">"; // TO
Result:
06-18 08:47:24.529: V/Mjsip-Test-App||(2191): Result: Timeout
06-18 08:47:24.828: I/System.out(2191): UA: NOT FOUND/TIMEOUT
Wireshark:
REGISTER sip:172.22.0.31:5554 SIP/2.0
Via: SIP/2.0/UDP 10.0.2.15:5554;rport;branch=z9hG4bK81091
Max-Forwards: 70
To: <sip:1001@172.22.0.31:5554>
From: <sip:1001@172.22.0.31:5554>;tag=z9hG4bK13966145
Call-ID: 270499704138@10.0.2.15
CSeq: 1 REGISTER
Contact: <sip:1001@172.22.0.31:5554>
Expires: 3600
User-Agent: mjsip stack 1.6
Content-Length: 0
INVITE sip:1001@172.22.0.31:5554 SIP/2.0
Via: SIP/2.0/UDP 10.0.2.15:5554;rport;branch=z9hG4bK35740
Max-Forwards: 70
To: <sip:1001@172.22.0.31:5554>
From: <sip:1001@10.0.2.15:5554>;tag=z9hG4bK16532567
Call-ID: 020447961933@10.0.2.15
CSeq: 1 INVITE
Contact: <sip:1001@10.0.2.15:5554>
Expires: 3600
User-Agent: mjsip stack 1.6
Content-Length: 145
Content-Type: application/sdp
v=0
o=sip:1001@10.0.2.15:5554 0 0 IN IP4 10.0.2.15
s=Session SIP/SDP
c=IN IP4 10.0.2.15
t=0 0
m=audio 3000 RTP/AVP 0
a=rtpmap:0 PCMU/8000
REGISTER sip:172.22.0.31:5554 SIP/2.0
Via: SIP/2.0/UDP 10.0.2.15:5554;rport;branch=z9hG4bK81091
Max-Forwards: 70
To: <sip:1001@172.22.0.31:5554>
From: <sip:1001@172.22.0.31:5554>;tag=z9hG4bK13966145
Call-ID: 270499704138@10.0.2.15
CSeq: 1 REGISTER
Contact: <sip:1001@172.22.0.31:5554>
Expires: 3600
User-Agent: mjsip stack 1.6
Content-Length: 0
edit5:如果我注册了 X-Lite,这就是 wireshark 跟踪的样子:
REGISTER sip:172.22.0.34 SIP/2.0
Via: SIP/2.0/UDP 172.22.0.33:38170;branch=z9hG4bK-d8754z-f3f38111bfc1d85a-1---d8754z-;rport
Max-Forwards: 70
Contact: <sip:1000@172.22.0.33:38170;rinstance=d3164432408a0132>;expires=0
To: "SipTestAcc1000"<sip:1000@172.22.0.34>
From: "SipTestAcc1000"<sip:1000@172.22.0.34>;tag=5f26a73a
Call-ID: YjAwMTQ2MmY4ZTU3MThhZjI2NTBlN2MwYTEzMWFjYTI
CSeq: 3 REGISTER
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
User-Agent: X-Lite release 4.5.2 stamp 70142
Authorization: Digest username="1000",realm="172.22.0.34",nonce="495a96a8-00d9-4d01-9976-0c1abd541874",uri="sip:172.22.0.34",response="b99aeb2f5c8f14282f91f6130d14b584",cnonce="efe1a8fc4b143d1f711fac8efe63e4e3",nc=00000002,qop=auth,algorithm=MD5
Content-Length: 0
NOTIFY sip:1000@172.22.0.33:38170 SIP/2.0
Via: SIP/2.0/UDP 172.22.0.34;rport;branch=z9hG4bKFaS6H1D4yU1cQ
Max-Forwards: 70
From: "SipTestAcc1000" <sip:1000@172.22.0.34>;tag=axGJLLkPBvdL
To: "SipTestAcc1000" <sip:1000@172.22.0.34>;tag=0079587c
Call-ID: MDE1OWU0ODEzMDY0NDU3N2M0NmQ0OWI1NTVkOGM5ZjE
CSeq: 45446966 NOTIFY
Contact: <sip:1000@172.22.0.34:5060>
Expires: 0
User-Agent: FreeSWITCH-mod_sofia/1.5.2b+git~20130607T065407Z~e7fa70416d
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, precondition, path, replaces
Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Subscription-State: terminated;reason=noresource
Content-Length: 0
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.22.0.34;rport=5060;branch=z9hG4bKFaS6H1D4yU1cQ
Contact: <sip:1000@172.22.0.33:38170>
To: "SipTestAcc1000"<sip:1000@172.22.0.34>;tag=0079587c
From: "SipTestAcc1000"<sip:1000@172.22.0.34>;tag=axGJLLkPBvdL
Call-ID: MDE1OWU0ODEzMDY0NDU3N2M0NmQ0OWI1NTVkOGM5ZjE
CSeq: 45446966 NOTIFY
User-Agent: X-Lite release 4.5.2 stamp 70142
Content-Length: 0
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.22.0.33:38170;branch=z9hG4bK-d8754z-f3f38111bfc1d85a-1---d8754z-;rport=38170
From: "SipTestAcc1000" <sip:1000@172.22.0.34>;tag=5f26a73a
To: "SipTestAcc1000" <sip:1000@172.22.0.34>;tag=FQZ535ytt8m1S
Call-ID: YjAwMTQ2MmY4ZTU3MThhZjI2NTBlN2MwYTEzMWFjYTI
CSeq: 3 REGISTER
Date: Tue, 18 Jun 2013 14:34:21 GMT
User-Agent: FreeSWITCH-mod_sofia/1.5.2b+git~20130607T065407Z~e7fa70416d
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, precondition, path, replaces
Content-Length: 0
SUBSCRIBE sip:1000@172.22.0.34:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 172.22.0.33:38170;branch=z9hG4bK-d8754z-64e0fd2ee573d443-1---d8754z-;rport
Max-Forwards: 70
Contact: <sip:1000@172.22.0.33:38170>
To: "SipTestAcc1000"<sip:1000@172.22.0.34>;tag=axGJLLkPBvdL
From: "SipTestAcc1000"<sip:1000@172.22.0.34>;tag=0079587c
Call-ID: MDE1OWU0ODEzMDY0NDU3N2M0NmQ0OWI1NTVkOGM5ZjE
CSeq: 3 SUBSCRIBE
Expires: 0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
Supported: eventlist
User-Agent: X-Lite release 4.5.2 stamp 70142
Event: message-summary
Content-Length: 0
SIP/2.0 202 Accepted
Via: SIP/2.0/UDP 172.22.0.33:38170;branch=z9hG4bK-d8754z-64e0fd2ee573d443-1---d8754z-;rport=38170
From: "SipTestAcc1000" <sip:1000@172.22.0.34>;tag=0079587c
To: "SipTestAcc1000" <sip:1000@172.22.0.34>;tag=axGJLLkPBvdL
Call-ID: MDE1OWU0ODEzMDY0NDU3N2M0NmQ0OWI1NTVkOGM5ZjE
CSeq: 3 SUBSCRIBE
Contact: <sip:1000@172.22.0.34:5060>
Expires: 0
User-Agent: FreeSWITCH-mod_sofia/1.5.2b+git~20130607T065407Z~e7fa70416d
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, precondition, path, replaces
Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Subscription-State: terminated;reason=noresource
Content-Length: 0
编辑6:当我尝试调用 toURL 时,FS 的日志:
2013-06-19 10:05:32.753652 [NOTICE] switch_channel.c:1027 New Channel sofia/internal/1001@172.22.0.34 [912a29fa-51db-4c87-86c1-e76eac1e2d5a]
2013-06-19 10:05:33.733181 [NOTICE] sofia.c:1786 Hangup sofia/internal/1001@172.22.0.34 [CS_NEW] [CALL_REJECTED]
2013-06-19 10:05:33.753690 [NOTICE] switch_core_session.c:1567 Session 15 (sofia/internal/1001@172.22.0.34) Ended
2013-06-19 10:05:33.753690 [NOTICE] switch_core_session.c:1571 Close Channel sofia/internal/1001@172.22.0.34 [CS_DESTROY]
edit7 在pc 的wlan 中使用真实设备进行测试:
06-20 09:48:23.576: V/Mjsip-Test-App||(9988): Start
06-20 09:48:23.584: V/Mjsip-Test-App||(9988): IP: 192.168.173.176
06-20 09:48:23.584: V/Mjsip-Test-App||(9988): Stack.init
06-20 09:48:23.599: V/Mjsip-Test-App||(9988): IP: 192.168.173.176 port: 5554
06-20 09:48:23.599: V/Mjsip-Test-App||(9988): new sipProvider created
06-20 09:48:23.599: V/Mjsip-Test-App||(9988): new profile
06-20 09:48:23.599: V/Mjsip-Test-App||(9988): From: <sip:1002@172.22.0.34>
06-20 09:48:23.599: V/Mjsip-Test-App||(9988): To: <sip:1002@172.22.0.34>
06-20 09:48:23.677: V/Mjsip-Test-App||(9988): reg.register()
06-20 09:50:31.678: V/Mjsip-Test-App||(9988): Listener: onUaRegistrationFailure
06-20 09:50:31.678: V/Mjsip-Test-App||(9988): RegisterAgent: org.hsc.sip.ua.core.core.RegisterAgent@405373f0
06-20 09:50:31.678: V/Mjsip-Test-App||(9988): target: <sip:1002@172.22.0.34>
06-20 09:50:31.678: V/Mjsip-Test-App||(9988): contact: <sip:1002@172.22.0.34>
06-20 09:50:31.678: V/Mjsip-Test-App||(9988): Result: Timeout
06-20 09:50:31.755: I/System.out(9988): UA: NOT FOUND/TIMEOUT
最佳答案
我不确定你是否成功地从模拟器向服务器发送请求(VM 中的 Freeswitch),你确定你可以在模拟器中使用 wifi 吗?即使 SIP 帧在 Wireshark 中,也不意味着它已到达目的地,它可能只意味着它已发送。 “通过”字段必须包含“真实/物理”IP 地址(在您的情况下)而不是“逻辑”(环回)地址,换句话说 127.0.0.1:5060 必须是发送设备的 IPv4 地址。您正在使用 IpAddress.getLocalHostAddress() 获取 Via 字段(与 SipProvider 构造函数中的参数相同的地址)返回 127.0.0.1,这只能意味着您的模拟器未“连接”到任何网络。我建议您更改默认端口,尝试“手动/静态”设置 via 地址(在 SipProvider 构造函数中)并验证您的虚拟网络设置。正如您在问题中提供的 REGISTER 消息一样,您似乎正在将 REGISTER 消息[返回]发送到 PC [可能是模拟器]而不是 VM。
REGISTER 消息没有 400 代码,400 SIP 代码代表“Bad Request”。
您必须提供注册失败原因(代码+原因),可以是以下之一(如果不是注册超时):
- “401 Unauthorized”:您必须重新发送带有身份验证(或 Www 身份验证) header 的 REGISTER 消息,该 header 包含从用户(注册)凭据生成的响应和服务器提供的“nonce”( key )回复第一个注册消息已发送。
- “403 Forbidden”:服务器拒绝“处理”您的请求。
- “404 Not found”:在服务器的“记录”中找不到请求的(注册)用户
- “407 Unauthorized”(不适用于您的情况)用于代理身份验证。
- 等等(full list of 4xx failure responses)
在 onUaRegistrationFailure() 方法中,在 Logcat 中打印“结果”字符串。 这个问题也可能是由于 MjSip 造成的,因为它的许多 API 都没有完全实现。
关于java - MJSIP:向服务器注册android客户端:onUaRegistrationFailure; Wireshark 400/错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17088017/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!