I’m setting up a new client, and want to send ‘SIP request’ to server ip address in my application. I tried many times in PHP, JAVA but I failed.
For example JAVA, when sending a request from the client is not given a response from the server.
import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;
public class Client
{
public static void main(String args[]) throws IOException
{
Socket socket = new Socket("104.207.221.19", 5060);
Scanner userInput = new Scanner(System.in);
Scanner socketInput = new Scanner(socket.getInputStream());
PrintStream socketOutput = new PrintStream(socket.getOutputStream());
String Request = "";
Request = "INVITE sip:bob@domain.com SIP/2.0
";
Request += "Via: SIP/2.0/UDP nm;received=51.40.80.23
";
Request += "From: <sip:nm@nm>;tag=root
";
Request += "To: <sip:nm2@nm2>;tag=dff4305d81b6facb
";
Request += "Call-ID: 50000
";
Request += "CSeq: 42 OPTIONS
";
Request += "Content-Type: application/sdp
";
Request += "
";
socketOutput.print(Request);
while(socketInput.hasNextLine())
System.out.println(socketInput.nextLine());
}
}
And in PHP using (https://github.com/level7systems/php-sip) library, when sending a request from the client to server IP(67.203.100.10), Given to me "exception 'PhpSIPException' with message 'Failed to bind 67.203.100.10:5071 The requested address is not valid in its context".
try
{
$api = new PhpSIP('67.203.100.10');
$api->setFrom('sip:john@sip.domain.com');
$api->setUri('sip:anna@sip.domain.com');
$api->setBody('Hi, can we meet at 5pm today?');
$res = $api->send();
echo "res1: $res
";
echo "response: $res
";
}
catch (Exception $e)
{
echo $e;
}