Azure EventHub ConnectionStringBuilder not returning the correct connection string - azure-eventhub

I am trying to get started with Eventhubs using the following link https://azure.microsoft.com/en-us/documentation/articles/event-hubs-java-storm-getstarted/.
When I pass the connection string directly to the ConnectionStringBuilder( connectionString), then the program sends data to the Eventhub. I notice that the connection string
starts with Endpoint=sb://....
but when I use ConnectionStringBuilder(namespaceName, eventHubName, sasKeyName, sasKey), I notice that the connectionstring created
starts with Endpoint=amqps://
and the program doesn't work and gives the following error
com.microsoft.azure.servicebus.AuthorizationFailedException: Attempted to perform an unauthorized operation.

I missed the last char of the SaSKey and so It didn't work...Sorry for this question

Related

A Regex that search for lines that contains a string, and not contains another string

I want to analyze an error log. So I decided to search for all the error header in the error log using Notepad++ so I can get all the first line of the errors on search result (which contains short description about the error) to determine if I need to look deeper into it. But the error log apparently is full of 'useless' error log from one kind of event, like 90% of it, so it kinds of hide the real error, like searching a needle in haystack.
So from this example made up error log:
ERROR on Server1: Network connection reset.
DETAIL: The client is gone.
ERROR on Server2: Network connection reset.
DETAIL: The client is gone.
ERROR on Server1: Network connection reset.
DETAIL: The client is gone.
ERROR on Server1: Null Pointer Error.
DETAIL: Object 'Cart' does not exists.
STACKTRACE:
at UpdateCart function
at AddProducttoCart function
ERROR on Server2: Network connection reset.
DETAIL: The client is gone.
ERROR on Server2: IO Error
DETAIL: The resource on URL (www.example.com/data.xls) does not exists.
ERROR on Server2: Network connection reset.
DETAIL: The client is gone.
I want to create a regex on Notepad++ search that search for line that contains string "ERROR on" but does not contain "Network connection reset", so the search result will only contain:
ERROR on Server1: Null Pointer Error.
ERROR on Server2: IO Error
How can I do that? I've read somewhere that inverse matching on regex is somewhat hard and unusual, but it's possible. Thanks.
Btw, I've tried some other way to do this, like finding for "ERROR on" + (.*) + "Network connection reset", then replace it with empty string, so that next time I search for "ERROR on", they will not appear. But the error log becomes scrambled with weird symbols after the search and replace, and Notepad++ kinda crashing after that. I don't know. I never have any luck search and replace on Notepad++ using regex.
I would use negative lookahead.
^(?!.*?\bNetwork connection reset\b).*\bERROR on\b.*
^ERROR on (?:(?!Network connection reset).)*$
You can use a lookahead in your regex.See demo.
https://regex101.com/r/pV0fH2/1

Google Native Client Visual Studio Add-in: Webserver fails to start because arguments to httpd.py are invalid

I have an application that I turned into a simple Native Client App a year ago, and I've been trying to get it running again. However, when I try to run it, or any of the example VS projects, the web server fails to start, giving me usage hints for httpd.py, and saying "httpd.py: error: unrecognized arguments: 5103".
I wasn't able to find anything about this on the NaCL guide or on the net. I could probably troubleshoot the issue if I could see the script that starts the webserver, but I have no idea where this is stored.
The script that start the server is 'nacl_sdk\pepper_43\tools\httpd.py'. The problem is with the port argument being formated incorrectly.
The expected format is:
httpd.py [-h] [-C SERVE_DIR] [-p PORT] [--no-dir-check]
But, the received arguments formatted by the add-in is:
['--no_dir_check', '5103']
where the port prefix is missing and should be '-p 5103'
For a quick fix, add the following line
parser.add_argument('args', nargs=argparse.REMAINDER)
before the parse_args(args) in the main(args) method in httpd.py.
This will keep the unknown arguments from being parsed and will use the default value for port instead (5103).

ora-24399- Invalid number of connections specified -OCCI program

I am using following simple code to connect to database and I am getting error as ORA-24399 which says invalid number of connections specified. I have googled enough but not clue. This is a CPP program.
Following is code Snippet:
try
{
Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Connection *con= env->createConnection("test","test","testdb");
}
catch(SQLException ex)
{
cout<<ex.getMessage().c_str();
}
P.S Using SQL Plus I am able to connect to the database where this code is being run. There are no issues there. Only through program there is a failure seen.
P.P.S Tried using connectionpool as well but still no luck...
Looking at your error, it seems that the problem is somewhere else in your code: you should fix the parameters (related to connection numbers) in the call to OCIConnectionPoolCreate.

How to Notice Close of MySql Server in Qt

When I closed MySql server, how can I understand that mysql server is gone away from my Qt program?
Edit:
Here my trial:
When I close MySql, I get these results, and I can't catch that MySql is closed.
My Code Snippet is
QSqlQuery query(db);
query.exec("SELECT * From RequestIds");
qDebug()<<query.lastError();
qDebug()<<db.lastError()<<QTime::currentTime();
qDebug()<<db.isOpen();
qDebug()<<db.isValid();
and output is:
QSqlError(2006, "QMYSQL: Unable to execute query", "MySQL server has gone away")
QSqlError(-1, "", "") QTime("14:22:58")
true
true
I don't understand why db.isOpen() returns true.
There is a bug related with QSqlDatabase::isOpen() in Qt.
https://bugreports.qt.io/browse/QTBUG-223
Your program has no idea of its surroundings. If something changes, you may be able to have the OS notify your program, or you'll have to test yourself.
If the database connection closes before your program, the status from the connection should return some kind of error code. You are checking status from the connection functions?
Write a simple program that opens a window and upon the click of a button, writes to the database. After writing to the database, the program should display the status in the window. Run your program. Press button to get the "controlled" response. Close the database then click on the button again.
You may be able to do this with a debugger, depending on the ability of the debugger & OS to queue up messages.
QSqlQuery::lastError() should give you an error if your query via QSqlQuery::exec() has failed. Also QSqlDatabase::isOpen() should report the state of your connection, QSqlDatabase::lastError() is also available
You can use isOpenError to determine whether opening the initial database connection was successfull. I agree that isOpen returning true is confusing.
To monitor the database connection I repeatedly try to open and close a lightweight MySQL connection (e.g. every 3 seconds):
#include <mysql/mysql.h>
mysql_init(&connection);
MYSQL *result = mysql_real_connect(&connection,
host.isNull() ? static_cast<const char *>(0) : host.toLocal8Bit().constData(),
user.isNull() ? static_cast<const char *>(0) : user.toLocal8Bit().constData(),
pass.isNull() ? static_cast<const char *>(0) : pass.toLocal8Bit().constData(),
dbName.isNull() ? static_cast<const char *>(0) : dbName.toLocal8Bit().constData(),
0,
0,
0);
bool currentlyConnected = (result != 0);
In the above example, host, user, pass, and dbName are QString instances containing the connection information. Note that you need the MySQL development headers.

Getting HTTP xml error response using cURL

I am currently using cURL to communicate to a cloud site... everything is going well except for an annoying issue. The issue is that I cannot get the site's xml response when there is an error. for example, when I use Wire Shark to check the transfer I can see that in the HTTP header that I'm getting which contains the error code; there is an XML data that contains in addition to the error code, a message that describes the code. I have tried many cURL options to try and get the XML but all my attempts failed.
Could someone tell me how can I get the XML. please note that I'm using the cURL C APIs as my code is in c++ and moreover, I can get XML responses when the operation succeeds using my write callback function.
Set CURLOPT_FAILONERROR to 0. If this is set to 1, then any HTTP response >= 300 will result in an error rather than processing like you want.