QAbstractSocket::UnknownSocketError - c++

What could be cause of QAbstractSocket::UnknownSocketError when using QTcpSocket?
CODE
I'm getting this error code with the following code:
this->connect(socket, SIGNAL(socketError(QAbstractSocket::SocketError)), SLOT(handleSocketError(QAbstractSocket::SocketError)));
...
void MyClass::handleSocketError(QAbstractSocket::SocketError error)
{
qDebug() << error;
}
MORE INFO
The QTcpSocket is trying to connect to some remote host. And it fails with mentioned error code.

If you read the code, you'll see that this error means exactly what it says: "something bad happened and I don't know why". There had to be exceptions, of course:
The socket is not connected to a server and you try to write to it (src/network/socket/qabstractsocket.cpp on line 2025)
An SSL error occurred (src/network/ssl/qsslsocket_openssl.cpp in a lot of places)
In both situations the errorString is set to an appropriate message.

Possibly you called the error() function when there is no error.

Looking for AbstractSocketError in the Qt sources gives quite some hits. Maybe fire up a debugger and look into the backtrace when you get the error() signal. Possibly an exotic error condition occured in the underlying socket engine (which is a Qt internal class).

Does remote host require ssl connection? It may be problem if your Qt copy can't load libssl. I had same problem (UnkownSocketError) when Qt couldn't find libssl

Related

Get text for error code returned by Poco?

I have an App with a Poco module for internet connection to support users with legacy XP and Vista OS connecting with TLS1.2. There is a connection problem that returns a Poco error code but I don't know what that means. Here is part of the logging output:
poco_connection::end_receiving_response_body entered
poco_connection::close entered
poco_session::destroy_connection entered
poco_connection::end_transaction entered (code 0x00280166, hresult 0x00000000, closing: FALSE)
--------- 043d7450 (Closing request)
poco_connection::transaction_notify entered (code 0x00280166, hresult 0x00000000): Status: 3
Poco Communication Failed: code 0x00280166, hresult 0x00000000
poco_connection::~poco_connection entered
A little research shows there is a class Poco::Error that includes a method
static std::string getMessage(
int errorCode
);
which returns a text string for errors. Unfortunately I don't have source for the Poco module and so I can't add that translation call.
Since Poco is an open source project, can anyone point me to a code location where I can look up the mapping of Poco errors? Specifically error code 0x00280166
Seems I got lucky with a bit of googling
https://github.com/pocoproject/poco/blob/develop/Foundation/src/Error.cpp
But I don't think you're in luck, the code just assumes the error code is a windows system error code. And when I google 0x00280166 this page is the only hit.

QCamera::start gives mysterious "failed to start" log message

It's just plain luck my program is so simple, so I eventually found out what causes the mysterious log message. My program log looks like this:
Debugging starts
failed to start
Debugging has finished
Which happens after:
camera = new QCamera(QCameraInfo::defaultCamera());
// see http://omg-it.works/how-to-grab-video-frames-directly-from-qcamera/
camera->setViewfinder(frameGrabber = new CameraFrameGrabber());
camera->start();
The start() method causes this message in console. Now the meaning of the message is obvious, what it's not very helpful. What steps should I take to troubleshoot it?
Reasons for this might differ, but in my case it was simply because I provided invalid QCameraInfo. The culprit is that QCameraInfo::defaultCamera() might return invalid value if Qt fails to detect any cameras on your system, which unfortunately happens even if cameras are present.

Unknown application error

So I`m writing an application for an embeded system (Linux on ARM) and everything works fine, until I decide to add one more class at the start of a main function. It looks like this (can not post the actual code here):
int main ()
{
Someclass class1;
....
}
And after that application just return code 1 (generic error) right from the start. If I remove it - everything is fine again. To me it looks like I ran out of stack space - but in that case system should throw a SIGSEV or SIGSTKFLT. But there was nothing just error code 1. I tried to get stderr like that:
./app 2> error.log
But there was also nothing.
Tried to debug using remote gdb:
Client:
Cannot access memory at address 0x3030204
Cannot access memory at address 0x3030200
Server:
Remote debugging from host xxxxxx
readchar: Got EOF
Remote side has terminated connection.
Details:
I`m wirting on C++11 (TR1) (project-specific), compile with GCC 4.4.6 (also project-specific), debug with GDB 7.4
Solved
Big thanks to everyone who responded, I have managed to solve this, and it was my fault - I did not initialized device`s libraries correctly before calling a wrapper class (later they were initialized and thus it worked). Thank you all again.
The most obvious place to look would be in the class' constructor which is being called on invocation of main.

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.

OUTDATED - Error modes for OpenCV

I am using OpenCV 1 to do some image processing, and am confused about the cvSetErrMode function (which is part of CxCore).
OpenCV has three error modes.
Leaf: The program is terminated after the error handler is called.
Parent: The program is not terminated, but the error handler is called.
Silent: Similar to Parent mode, but no error handler is called
At the start of my code, I call cvSetErrMode(CV_ErrModeParent) to switch from the default 'leaf' mode to 'parent' mode so my application is not terminated with an exception/assertion pop up.
Unfortunately 'parent' mode doesn't seem to be working. I still get the message dialog pop up, and my application still terminates.
If I call cvSetErrMode(CV_ErrModeSilent) then it actually goes silent, and no longer quits the application or throws up a dialog... but this also means that I dont know that an error has occurred. In this case, I think the mode is being set correctly.
Has anyone else seem this behaviour before and might be able to recommend a solution?
References:
cvSetErrMode function reference
Open CV Error handling mode reference
I am going to answer my own question, because after some fiddling around I have worked out what happens.
When you switch to 'parent' mode instead of leaf mode, there is an error handler that gets called cvGuiBoxReport(). cvGuiBoxReport() is the default error handler. It seems that even in parent mode, cvGuiBoxReport() still terminates your application! Oops.
So, to get around that you can write your own error handler, and redirect the error to be handled and NOT terminate the application.
An example error handler:
int MyErrorHandler(int status, const char* func_name, const char* err_msg, const char* file_name, int line, void*)
{
std::cerr << "Woohoo, my own custom error handler" << std::endl;
return 0;
}
You can set up parent mode and redirect your error with:
cvSetErrMode(CV_ErrModeParent);
cvRedirectError(MyErrorHandler);
In a week of servers crashing from uploading corrupt or empty images to our image processing server, here are some thoughts on how I solved the intricacies of OpenCV's error handling. We are using V2.2 in a C++ server.
The problem arises in cv::imread() and cv::imdecode() when the image to be loaded is corrupt (or empty). Normally OpenCV just exits the process with with some error messages, not a good idea when you're running a server which should work all the time.
Reviewing the source code at https://code.ros.org/trac/opencv/browser/trunk/opencv/modules/core/include/opencv2/core/core.hpp I ignored the hint in the source comments for cv::setBreakOnError() and discovered the that following pattern works:
cv::setBreakOnError(true); // Can be set globally
...
...
cv::Mat srcImage = cv::imread(filename, 1);
if (!srcImage.data) throw std::exception("bad image");
cv::imread() will now not exit the process, but passes control to your own exception handling, so you can do with it what you like.
Finding this has saved a lot of heartbreak.