Error 87: SystemServerNotFound using TM1API.dll in C#

Post Reply
Craig Trevor
Posts: 7
Joined: Tue Jul 28, 2009 4:43 am
OLAP Product: TM1
Version: 10.1.1
Excel Version: Excel 20010
Location: Brisbane, Australia

Error 87: SystemServerNotFound using TM1API.dll in C#

Post by Craig Trevor »

i am trying my hand at connecting to TM1 using the TM1API.dll in C#

I have managed to get it to compile and run (with help from http://forums.olapforums.com/viewtopic. ... 56&start=0).

I get an error 87: SystemServerNotFound, when i run it though.

Code: Select all

            TM1APIInitialize();
            hUser = TM1SystemOpen();
            TM1SystemAdminHostSet(hUser, "SERVERNAME");
            hPool = TM1ValPoolCreate(hUser);

            strServerName = "tm1 server";
            
            vServerName = TM1ValString(hPool, strServerName.Trim(), 0);

            hServer = TM1SystemServerConnectIntegratedLogin(hPool, vServerName);

            if (TM1ValType(hUser, hServer) == TM1ValTypeObject())
            {
                Console.WriteLine("Success");
            }
            if (TM1ValType(hUser, hServer) == TM1ValTypeError())
            {
                int nErrCode = TM1ValErrorCode(hUser, hServer);
                string szErrMsg = TM1ValErrorString(hUser, hServer);
                Console.WriteLine(nErrCode + ": " + szErrMsg);
            }

            TM1APIFinalize();
In the tm1s.cfg file I have 'IntegratedSecurityMode=2', and I have no issues logging into tm1 normally.

Is there something that I am missing?

Thanks in advance.
User avatar
Steve Rowe
Site Admin
Posts: 2456
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by Steve Rowe »

Hi,
SystemServerNotFound is I think the message you get when the address for host box that TM1 is running on is not found. Is it possible somewhere you have supplied the TM1 server name rather than the "box" name.
HTH
Technical Director
www.infocat.co.uk
Craig Trevor
Posts: 7
Joined: Tue Jul 28, 2009 4:43 am
OLAP Product: TM1
Version: 10.1.1
Excel Version: Excel 20010
Location: Brisbane, Australia

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by Craig Trevor »

'SERVERNAME' is the physical server box and 'tm1 server' is the name of the TM1 server.

I have tried different combinations of these to no avail.
jahn4
Posts: 3
Joined: Sun Aug 14, 2011 10:07 pm
OLAP Product: ibm cognos
Version: 9.4
Excel Version: 2007

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by jahn4 »

Hi,
I am also getting the same error code 87.
How did you fix this issue.

My Tm1s.cfg file is as below

ServerLogging=F
SecurityPackageName=Kerberos
IntegratedSecurityMode=1
UseSSL=T
ServerName=Planning Sample
DataBaseDirectory=C:\Program Files\Cognos\TM1\Custom\TM1Data\PlanSamp\
AdminHost=HOME
PortNumber=5000
ClientMessagePortNumber=
Language=ENG
SaveTime=
DownTime=
ProgressMessage=True
AuditLogOn=F
AuditLogMaxFileSize= 100 MB
AuditLogUpdateInterval=60


----------------------------------------------------

My server name= 'local'
I am using visual studio c++ for my C code..pls see my code snippet below..

***********************************************************
char * sClientId = "Admin";
char * sServerName = "local";
char * sPassword = "";

char * sAdminHost = "HOME";
TM1SystemAdminHostSet (hUser,(CHAR *) sAdminHost);

hPool = TM1ValPoolCreate( hUser );

hServer = TM1SystemServerConnect
(
hPool,
TM1ValString( hPool, sServerName, 10),
TM1ValString( hPool, sClientId, 10 ),
TM1ValString( hPool, sPassword, 10 )
);

//hServer = TM1SystemServerHandle( hUser, sServerName );

if( TM1ValType( hUser, hServer ) == TM1ValTypeError() )
{
TM1_INDEX ErrorCode1 = TM1ValErrorCode(hUser, hServer);


char* errorStr = TM1ValErrorString(hUser, TM1ValIndex(hUser,ErrorCode1));
std::cout << "Cannot connect the database: Error_code= " << ErrorCode1 <<" Error_str= " << errorStr <<std::endl;

return;
}
*************************************************************************
Please help me out..
Kyro
Community Contributor
Posts: 126
Joined: Tue Nov 03, 2009 7:46 pm
OLAP Product: MODLR - The CPM Cloud
Version: Always the latest.
Excel Version: 365
Location: Sydney, Australia
Contact:

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by Kyro »

Jahn - Your situation is perplexing, you have a TM1 config file with "ServerName=Planning Sample" and "AdminHost=HOME" yet you say
My server name= 'local'
.

I think you should probably read the TM1 Operations guide, specifically the chapter on "TM1 System Architecture" / "TM1 Admin Server".

Other then that there are a few other issues with your approach:
  • TM1ValString( hPool, sServerName, 10) will limit the given string to 10 characters every time. So if you did set the correct parameters your server name parameter would end up as "Planning Sa"
  • Pretty sure - char* errorStr = TM1ValErrorString(hUser, TM1ValIndex(hUser,ErrorCode1)); is just plain wrong. But it may work if the function is able to use error codes as well as error handles?
  • Your hard coding all of your credentials?
jahn4
Posts: 3
Joined: Sun Aug 14, 2011 10:07 pm
OLAP Product: ibm cognos
Version: 9.4
Excel Version: 2007

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by jahn4 »

Thanks Kyro.
I am just a newbie trying to learn.
i changed my Tm1s.cfg file as below.
------------------------------------------------------------------
ServerLogging=F
SecurityPackageName=Kerberos
IntegratedSecurityMode=1
UseSSL=T
ServerName=local
DataBaseDirectory=C:\Program Files\Cognos\TM1\Custom\TM1Data\PlanSamp\
AdminHost=HOME
PortNumber=5000
ClientMessagePortNumber=
Language=ENG
SaveTime=
DownTime=
ProgressMessage=True
AuditLogOn=F
AuditLogMaxFileSize= 100 MB
AuditLogUpdateInterval=60

----------------------------------------------------
Machine name is 'HOME'..hence during installation it took admin name as 'H'OME'
As you can as many servers as possible on the same machine as long as they can have different port numbers.
I created 'local' named server running on port 5000..

You are right...this statement does not work..it hangs here.
char* errorStr = TM1ValErrorString(hUser, TM1ValIndex(hUser,ErrorCode1));
but when i was debugging, i am still getting error code 87..
the method "TM1SystemServerConnect" is not returning correct server handle..it returns a 'unsigned long* ' type with error code 87..

I also changed the below code also.

Code: Select all

TM1V vUserName = TM1ValString(hPool, (CHAR *) sClientId, 100);
TM1V vServerName = TM1ValString(hPool, (CHAR *) sServerName, 100);
TM1V vPassword = TM1ValString(hPool, (CHAR *) sPassword, 100);
i am thinking the program is not able to make call to get server handle via microsoft SDK.. :?:
I am loading the dll using

Code: Select all

HINSTANCE hinstLib = LoadLibrary(TEXT("Tm1api.dll"));
is there anything i should be doing to MS visual studio to include any SDK components..?
I dont know what could be done..

I am based in California.

Thanks
Kyro
Community Contributor
Posts: 126
Joined: Tue Nov 03, 2009 7:46 pm
OLAP Product: MODLR - The CPM Cloud
Version: Always the latest.
Excel Version: 365
Location: Sydney, Australia
Contact:

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by Kyro »

Based on what we are talking through, I think your problem is not your code - but instead whether or not you are actually running a TM1 server correctly.

For completeness, heres an extracted code snippet you can use from one of my TM1 Utility Console Applications to test. This was made in VS C++ 2008. I think you have linked the correct libraries as otherwise the linker would have trouble compiling a binary.

Code: Select all

		TM1U hUser = TM1SystemOpen();
		TM1P pGeneral = TM1ValPoolCreate(hUser);
		TM1SystemAdminHostSet(hUser,(char *) args[4].c_str());

		TM1V vServer = TM1ValString(pGeneral,(char *) args[3].c_str(),args[3].length());
		TM1V vU = TM1ValString(pGeneral,(char *) args[1].c_str(),args[1].length());
		TM1V vP = TM1ValString(pGeneral,(char *) args[2].c_str(),args[2].length());
		
		TM1V hServer = TM1SystemServerConnect( pGeneral, vServer, vU, vP );
		if( TM1ValType(hUser,hServer) == TM1ValTypeObject() ) {
			//CONTINUE WITH YOUR ACTUAL PURPOSE
			cout << "Connection Succeeded" << endl;
			TM1SystemServerDisconnect(pGeneral,hServer);
 		} else {
			//ERROR REPORTING
			cout << "Error: Failed to connect to the server - TM1 Message:" << endl;
			cout << TM1ValErrorString(hUser, hServer) << endl;
		}
		TM1ValPoolDestroy(pGeneral);
		TM1SystemClose(hUser);
As a command line for this quick little app you could add "username" "password" "server" "adminhost" - sorry about the order, just wrote all the command line stuff in the forum editor - so excuse me if there are any syntax errors.

I think its worth going through the process of setting up servers using the different methods - Local, Application Shortcut, NT Service and cement your knowledge around how servers behave before continuing though.

Edit: Just a thought, make sure you are running/debugging your binary from a folder which has the standard dll files but also the ssl folder. Otherwise you'll get the "server not found" message that you are reporting.
jahn4
Posts: 3
Joined: Sun Aug 14, 2011 10:07 pm
OLAP Product: ibm cognos
Version: 9.4
Excel Version: 2007

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by jahn4 »

Thanks Kyro..
It is working now..All i did was to copy ssl folder, TM1API.dll and tm1api.lib into the folder where the binary file for the client program is located..
That seems to have done the trick.

well..I appreciate your help on this mate.. :)
Thanks
Kyro
Community Contributor
Posts: 126
Joined: Tue Nov 03, 2009 7:46 pm
OLAP Product: MODLR - The CPM Cloud
Version: Always the latest.
Excel Version: 365
Location: Sydney, Australia
Contact:

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by Kyro »

Not a problem, let me now if your ever in Sydney, I'll buy you a beer and you can tell/show me what you've built.
michael_gcph
Posts: 4
Joined: Sat Jul 28, 2012 5:22 pm
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2010

Re: Error 87: SystemServerNotFound using TM1API.dll in C#

Post by michael_gcph »

hi jahn4, just an update, I was coding and compiling via C and i did encounter the same problem as what you have. It is indeed because of the ssl folder not being in the executable path. Thank you so much!
Life is like a rock.......... It's hard.
Post Reply