Jump to content

Recommended Posts

Posted

Hi, i'm in the process to make a php extension for Eset Remote Administrator. the process never pass "Era.ServerApi.CreateConnectionRequests" always return error "ConvertProtobufStringToProtobufObject". what may cause this error?

{"Era.ServerApi.SimpleResponse": {"result":true} }
----------------[{"Era.ServerApi.CreateConnectionRequests":{"host":"127.0.0.1","port":"8080"}}]-----------------------
{"Era.ServerApi.SimpleResponse": {"result":false,"error":"ConvertProtobufStringToProtobufObject failed with: map::at"} }
{"Era.ServerApi.SimpleResponse": {"result":false,"error":"Active session does not exist"} }
{"Era.ServerApi.SimpleResponse": {"result":true} }

my environment : ERA Version 6.5 (6.5.417.0) running on Linux x86_64, gcc version 4.8.5, PHP 5.4.16 (cli and web). 

thanks in advance

  • ESET Staff
Posted

Just guessing, but I think you should replace:

"Era.ServerApi.CreateConnectionRequests"

with:

"Era.ServerApi.CreateConnectionRequest"

because you are trying to create call to non-existing method.

Have you found it in documentation? If so, please provide more details so that it can be fixed.

Posted

thank you MartinK.

woops. my bad, i thought the problem was about wrongly formated input. now i get different message. here is the response message

{"Era.ServerApi.SimpleResponse": {"result":false,"error":"std::bad_cast"} }

here is the c++ code

char* szRes;
int sendstatus;
std::string
createConnectionRequest = "{\"Era.ServerApi.CreateConnectionRequest\":{\"host\":\"";
createConnectionRequest += host;
createConnectionRequest += "\",\"port\":";
createConnectionRequest += port;
createConnectionRequest += "}}";

szRes = NULL;
std::cout << "[" << createConnectionRequest << "]\n";
sendstatus = process_request( createConnectionRequest.c_str(), &szRes);
if (szRes)
{
	std::cout<<szRes<<"\nstatus : " << sendstatus << std::endl;
	free_response(szRes);
}

 

actually if documentation about this error messages, or about "era_init_lib", "era_process_request", "era_deinit_lib", "era_free"  is available somewhere i'd love to know. 

  • ESET Staff
Posted

This time problem is with port. According to API documentation, it should be integer, but you are sending request with string. Removing quotes around 8080 should be sufficient.

Posted

if you read my c++ code on my second post, i already remove the quote around port number, and the response is bad_cast. Since i'm building in linux probably there is some compatibility issue?  here is how i initialize "era_process_request" . 

void* serverAPI;
int (*process_request)(const char*, char**);

serverAPI = dlopen("/opt/eset/RemoteAdministrator/Server/ServerApi.so", RTLD_LAZY);
process_request = reinterpret_cast<int(*)(const char*, char**)>(dlsym(serverAPI, "era_process_request"));

i mess around with string type, both (const char*) and (char*) produce similar result, bad_cast. 

  • ESET Staff
Posted

Unfortunately this time I don't see any obvious reason for this error. I have only one question - seems that you are using port 8080, but by default, ERA uses port 2223 for accepting ServerApi connections.

Regarding requests, I would recommend to follow API example from documentation, which shows that before create connection request can be processed, it is required to call Era.ServerApi.StartRequest: have you done that? If that won't help, it should be possible to enable trace logging of API, which may be more helpful.

Posted

thank you MartinK

i'm sure, the server api have not use the port and host data yet. since it's having trouble to read those data right? i wish i could tell which field is  the API trying to cast? and from what type to what type? this is dynamic_cast problem isn't it?

i did change those values with various possible value, "localhost", 127.0.0.1, direct ip, also try to change the port, possible combinations of both, and no luck. still bad_cast. 

initiating libraries, status : ERA_SUCCESS
{"Era.ServerApi.SimpleResponse": {"result":true} }
status : 0
[{"Era.ServerApi.CreateConnectionRequest":{"host":"127.0.0.1","port":2223}}]
{"Era.ServerApi.SimpleResponse": {"result":false,"error":"std::bad_cast"} }

so, i've confirmed so far the "ConvertProtobufStringToProtobufObject" means malformed json, or unrecognized json element. for the bad_cast i must say it is impossible to hack through, insufficient information. thanks for the help. 

  • ESET Staff
Posted

as you noted, this does not seems to be a problem with parsing request. I think there is something not properly initialized and that is why it fails once request has proper format.

Please double check you did not miss any required step that has to be done before requests are called. If I recall correctly, there are few initialization calls that has to be made. One of them includes possibility to enable trace logging, which may also help in this case.

Posted

hi MartinK, i've enabled logging to "stdout" and set the message level to "Trace" . i got these output. i still can't figure out what is wrong. 

here is the full output

[###]
initiating libraries, status : ERA_SUCCESS
logging options
{"Era.ServerApi.SimpleResponse": {"result":true} }
status : 0
start server API
{"Era.ServerApi.SimpleResponse": {"result":true} }
status : 0
create connection
[{"Era.ServerApi.CreateConnectionRequest":{"port":2223,"host":"127.0.0.1"}}]
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f37fff700]: Received message: CreateConnectionRequest
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3d64d700]: Forcibly closing sessionId:1, isClosing:0
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3d64d700]: Removing session 1
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3d64d700]: Closing connection , session id:1
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3de4e700]: Sending message: ConnectionFailure
{"Era.ServerApi.SimpleResponse": {"result":false,"error":"std::bad_cast"} }
status : 0
close connection
{"Era.ServerApi.SimpleResponse": {"result":false,"error":"Active session does not exist"} }
status : 0
stop server API
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: OnStop. Force: 1, ClientProxy size: 0
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: Waiting for shutdown ...
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: Stopping main container ...
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: CContainer stopping statusLogGenerator
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: CContainer stopping requestHandlerConsoleClient
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: Stopping RequestHandler. Session count:0
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: CContainer stopping invocationJobSchedulerConsole
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: Stopping network proxy scheduler ...
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f42669740]: Shutdown complete, ready to get unloaded ...
{"Era.ServerApi.SimpleResponse": {"result":true} }
status : 0
exit lib
[root

here are things that happening before the "bad_cast". i cant tell what's wrong there. 

[{"Era.ServerApi.CreateConnectionRequest":{"port":2223,"host":"127.0.0.1"}}]
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f37fff700]: Received message: CreateConnectionRequest
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3d64d700]: Forcibly closing sessionId:1, isClosing:0
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3d64d700]: Removing session 1
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3d64d700]: Closing connection , session id:1
2017-11-03 07:52:54 Information: NetworkModule [Thread 7f9f3de4e700]: Sending message: ConnectionFailure
{"Era.ServerApi.SimpleResponse": {"result":false,"error":"std::bad_cast"} }

 

Posted

Yesterday i tested build my app in new VM which runs ubuntu, same code, same configuration, and it successfully run and connecting. Today  my coworker download and build gcc 5.4 manually in the same VM (centos x64, and gcc 4.8) i previously use. with the new gcc the code working. I think this is compiler issue.

  • ESET Staff
Posted
12 hours ago, kornwaretm said:

Yesterday i tested build my app in new VM which runs ubuntu, same code, same configuration, and it successfully run and connecting. Today  my coworker download and build gcc 5.4 manually in the same VM (centos x64, and gcc 4.8) i previously use. with the new gcc the code working. I think this is compiler issue.

Happy to hear that as we were not able to reproduce nor we had any similar reports. Unfortunately documentation (nor testing) includes any compiler/linker details, but it is probable that not all configurations will work.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...