简体   繁体   中英

Connect Android SIP to OfficeSip server

I am developing an Android SIP client. I'd like to test it against OfficeSip server. So I have set up the officeSip server locally and I can connect to it via officeSIP messenger (the client).

The messenger requires this data to login:

  • List item
  • addr: username@server_domain
  • username: username
  • password: password
  • protocol: protocol
  • server address: server address

However, when trying to do the same in Android, its SipProfile.Builder has a bit different parameters. Of note are the following:

public SipProfile.Builder (String username, String serverDomain)
public SipProfile.Builder setOutboundProxy (String outboundProxy)

There doesn't seem to be a server address available.

I have tried the following for serverDomain parameter:

  • user@server_domain/server_ip
  • server_domain/server_ip
  • server_domain@server_ip
  • many other combinations

However, I'm either getting connection error (when @ is used) or registration failed event (when / is used with server IP after the /). Error codes are -4 (When some error occurs on the device, possibly due to a bug) first, immediately followed by -9 (The client is in a transaction and cannot initiate a new one)

How can I connect to OfficeSIP using Android SIP client?

Edit: I managed to establish communication with CSipSimpleClient which uses a custom SIP stack. It only required server name (equal to server's domain), username and password.

I'm not sure.. but '@' and '/' are not allowed and SipProfile.Builder will make a URI, eg "username@serverDomain(or ip)", with username and serverDomain parameters. Just try to set like this.. ("user1", "test.com"), ("user1", "1.1.1.1").

API description says "the SIP server domain; if the network address is different from the domain, use setOutboundProxy(String) to set server address" about serverDomain.

Turns out, Android SIP stack is quite immature and finnicky.

Ultimately I was able to connect by specifying both server hostname and server proxy. Also, if server domain differs from computer name server is running on, you WILL have issues connecting. Domain must match either IP address or computer name, but they must match in order to connect via Android SIP client.

I have successfully connected to OfficeSIP with the android SIP API.

  1. Download the SipDemo here
  2. In WalkieTalkieActivity.java I modified the code to be the following:

    SipProfile.Builder builder = new SipProfile.Builder("test", "officesip.local");

    builder.setPassword("test");

    builder.setOutboundProxy("192.168.10.191");

    builder.setAutoRegistration(true);

    me = builder.build();

  3. In OfficeSIP test is the user with a password also test. The outbound proxy is the IP of the computer or server hosting OfficeSIP and officesip.local is the SIP domain name, which can be found in OfficeSIP under ther settings tab.

  4. To test this I made a second account on OfficeSIP and logged into that account using Sipdroid. From there I called the SipDemo app running on a second phone and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM