- Joined
- Mar 21, 2017
- Messages
- 16
- Reaction score
- 0
Hi
I am using the Call Control Api .Net library , i am using a free version 14 of 3CX, now not even sure if the API is meant to work with the free version
When i try and use the connections settings i think i should be using [ConfService] (below) i keep getting the IsNotConnected exception.
However when i use the values under [General] section , I can connect and MakeACall but any interaction with the PhoneSystem I get the Config server is not connected error.
I was just messing about with the setting and somehow got it to connected and make a call but now can't do much beyond that.
Just writing a simple program to test out first my .ini file looks as below
My .NET code is below , note the connection if working OFF the Default values from my testing it cannot pick up CM_API_IP etc from the system.
So the code below works fine and makes the call ..
if i uncomment this line DN dn = PhoneSystem.Root.GetDNByNumber("852"); the call is still made but in the console an exception is thrown and I cannot do other things i want to .
Any ideas at all...
I am using the Call Control Api .Net library , i am using a free version 14 of 3CX, now not even sure if the API is meant to work with the free version
When i try and use the connections settings i think i should be using [ConfService] (below) i keep getting the IsNotConnected exception.
However when i use the values under [General] section , I can connect and MakeACall but any interaction with the PhoneSystem I get the Config server is not connected error.
I was just messing about with the setting and somehow got it to connected and make a call but now can't do much beyond that.
Just writing a simple program to test out first my .ini file looks as below
Code:
2[General]
;connection point to call manager
;used by:
;a) call manager initializes own listener before it connects to configuration server.
;b) components which are working directly with call manager
;MUST NOT be used by components which make connection to configuration server.
;They MUST use CM_API_IP, CM_API_PORT, CM_API_USER and CM_API_PASSWORD paramaeters to make direct connection to CallManagerAPI
pbxSLNIC=127.0.0.1
cmPort=5482
pbxuser=instance_instance127750
pbxpass=42ov2rvu16n
AppPath=C:\Program Files\3CX Phone System\Instance1
AppDataPath=C:\ProgramData\3CX\Instance1
Tenant=instance1
[ConfService]
;connection point to configuration server for components
confNIC=127.0.0.1
ConfPort=5485
confUser=cfguser_default
confPass=pwhshhlew3va
PhoneSystem.ApplicationName = "UniqueName"
[CfgServerProfile]
;configuration server connection to database
;exclusively used by configuration server
DBHost=127.0.0.1
DBPort=5480
MasterDBUser=phonesystem
MasterDBPassword=Uoi5CIvezBEwTJ
MasterTable=phonesystem_mastertable
DefFile=Objects.cls
[QMDatabase]
DBHost=127.0.0.1
DBPort=5480
DBName=database_single
dbUser=logsreader_single
dbPassword=47z7x0tco5hs
[MIME_TYPES]
MESSAGE=x-chat/control
My .NET code is below , note the connection if working OFF the Default values from my testing it cannot pick up CM_API_IP etc from the system.
So the code below works fine and makes the call ..
if i uncomment this line DN dn = PhoneSystem.Root.GetDNByNumber("852"); the call is still made but in the console an exception is thrown and I cannot do other things i want to .
Any ideas at all...
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TCX.Configuration;
using TCX.PBXAPI;
namespace _3cxTest
{
class Program
{
static void Main(string[] args)
{
PBXConnection pbx = CreatePbxConn();
try
{
pbx.MakeCall("852", "12");
// DN dn = PhoneSystem.Root.GetDNByNumber("852");
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
public static TCX.PBXAPI.PBXConnection CreatePbxConn(string host, int port, string user, string password)
{
return new TCX.PBXAPI.PBXConnection(host, port, user, password);
// return new TCX.PBXAPI.PBXConnection("127.0.0.1", 5482, "instance_instance127750", "42ov2rvu16n");
}
public static TCX.PBXAPI.PBXConnection CreatePbxConn()
{
//v14 (cloud and in premiss) - stores pbx API connection parameters in configuration.
//ini file is not required to obtain this information.
bool exists = false;
/// return new TCX.PBXAPI.PBXConnection("127.0.0.1", 5485, "cfguser_default", "pwhshhlew3va");
return CreatePbxConn(
GetParameterValue("CM_API_IP", "127.0.0.1", ref exists),
int.Parse(GetParameterValue("CM_API_PORT", "5482", ref exists)),
GetParameterValue("CM_API_USER", "instance_instance127750", ref exists),
GetParameterValue("CM_API_PASSWORD", "42ov2rvu16n", ref exists));
}
public static string GetParameterValue(string name, string DefaultValue, ref bool exists)
{
try
{
exists = true;
return TCX.Configuration.PhoneSystem.Root.GetParameterByName(name).Value;
}
catch
{
exists = false;
return DefaultValue;
}
}
}
}