Using TLS in pjsua application - voip

I am trying to use TLS in pjsua app, but i get an error here:
try{
ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TLS, sipTpConfig);
} catch (Exception e) {
System.out.println(e);
}
The error is: Code: 171060 unsupported transport (pjsip_eunsuptransport).
Do you know something about it?

Related

Library for Android httpPost

It's kinda frustating me... I tried to create httpPost
code :
private void makePostRequest() {
HttpClient httpClient = new DefaultHttpClient();
// replace with your url
HttpPost httpPost = new HttpPost("www.example.com");
//Post Data
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
nameValuePair.add(new BasicNameValuePair("username", "test_user"));
nameValuePair.add(new BasicNameValuePair("password", "123456789"));
//Encoding POST data
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
// log exception
e.printStackTrace();
}
//making POST request.
try {
HttpResponse response = httpClient.execute(httpPost);
// write response to log
Log.d("Http Post Response:", response.toString());
} catch (ClientProtocolException e) {
// Log exception
e.printStackTrace();
} catch (IOException e) {
// Log exception
e.printStackTrace();
}
}
But always ended Can't resolve symbol. I used Android Studio latest update, I already downloaded http://mirror.metrocast.net/apache//httpcomponents/httpclient/binary/httpcomponents-client-4.5-bin.zip from hc.apache.org and copy jar file (httpclient-4.5.jar and httpcore-4.4.1.jar) to library and add it as a library but somehow it doesn't work.
It gives error :
Error:Execution failed for task ':app:packageDebug'.
Duplicate files copied in APK META-INF/DEPENDENCIES File 1: Z:\Learning\Android-2\Live-code-AS\SendLocation\app\libs\httpcore-4.4.1.jar
File 2:
Z:\Learning\Android-2\Live-code-AS\SendLocation\app\libs\httpclient-4.5.jar
if I delete one of the jar file then I'll get "can't resolve HttpClient or NameValuePair"
Please help.... Thanks before.
You have some duplicate files in your dependencies. To solve it, open your build.gradle in which you define your dependencies and add the packagingOptions-section within the android-section:
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}

Axis fault : faultString: java.io.IOException for suitetalk

I am trying to use NetSuite's suiteTalk java api for writing an interface between our lotus notes system and NetSuite.
The first error thrown by the code was a class def not found error.
for :
sun/security.provider/sun.class
sun/security.provider/sun$1.class
sun/security.provider/NativePRNG.class
I figured out that rt.jar in lotus notes was actually missing this files. So I added these class files from the jdk1.6 i had downloaded separately. Once I fixed that I started getting axis.Faults error.
Here is the simple login code that I am trying to execute from lotus note agent:
public void loginTest(){
NetSuitePortType _port=null;
// In order to use SSL forwarding for SOAP message. Refer to FAQ for details
System.setProperty("axis.socketSecureFactory","org.apache.axis.components.net.SunFakeTrustSocketFactory");
// Locate the NetSuite web service
NetSuiteServiceLocator serviceLocator= new NetSuiteServiceLocator();
//Get the service port
try {
_port=serviceLocator.getNetSuitePort();
} catch (ServiceException e) {
System.out.println("Error in intializing GlobalSuiteTalkSetup");
e.printStackTrace();
}
// Setting client timeout to 2 hours for long running operatotions
((NetSuiteBindingStub) _port).setTimeout(60*60*1000*2);
try {
// Populate Passport object with all login information
Passport passport = new Passport();
RecordRef role = new RecordRef();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
passport.setEmail("username");
passport.setPassword("password.");
role.setInternalId("3");
passport.setRole(role);
passport.setAccount("111111");
// Login to NetSuite
System.out.print("\nLogging into NetSuite");
System.out.print(" Username: " + passport.getEmail());
System.out.print(" Account: " + passport.getAccount());
System.out.print(" password: " + passport.getPassword());
System.out.print(" role: " + passport.getRole());
Status status;
status = (_port.login(passport)).getStatus();
// Process the response
if (status.isIsSuccess() == true)
{
System.out.print("\nThe login was successful and a new session has been created.");
} else
{
// Should never get here since any problems with the
// login should have resulted in a SOAP fault
System.out.print("Login failed");
//System.out.print(getStatusDetails(status));
}
} catch (InvalidVersionFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidCredentialsFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InsufficientPermissionFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExceededRequestLimitFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnexpectedErrorFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAccountFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Error thrown by code:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.io.IOException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.io.IOException
at org.apache.axis.components.net.SunJSSESocketFactory.initFactory(SunJSSESocketFactory.java:88)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:79)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.netsuite.webservices.platform_2015_1.NetSuiteBindingStub.login(NetSuiteBindingStub.java:12799)
at Login.loginTest(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
{http://xml.apache.org/axis/}hostname:
java.io.IOException
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.netsuite.webservices.platform_2015_1.NetSuiteBindingStub.login(NetSuiteBindingStub.java:12799)
at Login.loginTest(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
Caused by: java.io.IOException
at org.apache.axis.components.net.SunJSSESocketFactory.initFactory(SunJSSESocketFactory.java:88)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:79)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
... 14 more
I found the solution for this issue. For anyone who might get similar issue can get some clue from this solution :
The issue was because of the following statement that I had put in the code.
System.setProperty("axis.socketSecureFactory","org.apache.axis.components.net.SunFakeTrustSocketFactory");
This statement is necessary when using Sun' JVM but since Lotus Notes uses IBM's JVM, setting axis.socketSecureFactory to org.apache.axis.components.net.SunFakeTrustSocketFactory made the system to look for Sun classes which not absent in IBM's JVM.
No need to add the missing classes from Sun JVM to rt.jat as I had done before. Just comment that statement and use the axis path available frpm NetSuite
Don't forget to put the patch in Note's /JVM/Lib/EXT folder and restart Lotus Notes before trying to run the code..

Catch MFC exception

Trying to catch MFC exception with macros:
TRY
{
// Do something to throw an exception.
}
CATCH(CException, e)
{
}
END_CATCH
How to get this error description message ?
Use CException::GetErrorMessage. You get the text with this call.

Midlet crashes when calling bluetooth API

When I run following code on my phone I get black screen saying there was uncaught exception but whole block is wrapped in try/catch block so it is weird, anyway when I proceed with execution code just gets to "Getting device.." so it obviously fails on this line:
LocalDevice local = LocalDevice.getLocalDevice();
Here is whole method:
public void startBT()
{
try
{
f.append("Getting device..");
LocalDevice local = LocalDevice.getLocalDevice();
f.append("Got local device..");
DiscoveryAgent agent = local.getDiscoveryAgent();
f.append("Got local discovery agent..");
connString = agent.selectService(new UUID(
"86b4d249fb8844d6a756ec265dd1f6a3", false),
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
f.append("Got connection string - >" + connString);
}
catch (Exception ex)
{
Alert message = new Alert("info");
message.setString(ex.getMessage());
Display.getDisplay(this).setCurrent(message);
}
}
Any ideas?
It looks like device I used doesn't support JSR-82 which is J2ME Bluetooth API(this is built into phone, no way of "installing" it) required to use Bluetooth from J2ME Midlets,here is snippet which should check for JSR-82 support:
public static boolean IsBtJsrComaptible() {
try {
Class.forName("javax.bluetooth.LocalDevice");
return true;
} catch (Exception e) {
return false;
}
}
Please note that I got uncaught exception trying to run above snippet, but maybe it would work on some other device.

Failed to connect [10048]

I've got this code on a button, when I press it I get the Error:
Error: Exception connecting to NXT.
Caused by lejos.pc.comm.NXTCommException: Open of NXT failed.
at lejos.pc.comm.NXTCommBluecove.open(NXTCommBluecove.java:136)
Caused by javax.bluetooth.BluetoothConnectionException: Failed to connect; [10048]
Only one usage of each socket address (protocol/network address/port) is normally permitted.
at com.intel.bluetooth.BluetoothStackMicrosoft.connect(Native Method)
Failed to connect to any NXT
I am posting because it was working fine yesterday but seems not to be working today.
btnConnectBot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (Cnt1){
try {
conn.close();
Cnt1=!Cnt1;
txtConnState.setText("Off");
txtConnState.setForeground(Color.RED);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else{
conn.addLogListener(new NXTCommLogListener() {
public void logEvent(String message) {
System.out.println(message);
}
public void logEvent(Throwable throwable) {
System.err.println(throwable.getMessage());
}
});
conn.setDebug(true);
if (!conn.connectTo(txtBotName.getText(), NXTComm.LCP)) {
System.err.println("Fallo de conexión");
txtConnState.setText("Off");
txtConnState.setForeground(Color.RED);
System.exit(1);
}
Cnt1=!Cnt1;
txtConnState.setText("On");
txtConnState.setForeground(Color.GREEN);
if (chckbxLock_2.isSelected()){
btnConnectBot_2.doClick();
}
if (chckbxLock_1.isSelected()){
btnConnectBot_1.doClick();
}
}
}
});
According to my research this is because the bluetooth port being used is being accessed by more than one instance. But I don't see how this happens in this code.
Do you have a Bluetooth virtual COM port configured for the remote device? Maybe it is opened by some program...
Or, does the error occur the first time you run your program? Are there any old copies of your program running -- check in taskmgr.exe

Resources