zeromq / zeromq4-x

ØMQ 4.x stable release branch - bug fixes only
GNU General Public License v3.0
456 stars 194 forks source link

Assertion Failed: Permission Denied #160

Open wenjians opened 7 years ago

wenjians commented 7 years ago

I'm developing an application on Windows 10 with ZeroMQ for some background connection. I'm using Visual Studio 2008 C++ and ZeroMQ version 4.0.4.

When ZeroMQ connection and send the data, Windows will popup an exception with message box "Unhandled exception at ...". When I built a simple console application, in console output, there was a message "Assertion failed: Permission denied (......\src\tcp_connecter.cpp:284)".

There is no exception if I choose no-blocking the connection.

I tried to catch the error, while there was no exception captured, so I understand it might because of ZeroMQ background task. This style of error pop up is not friend to customer and I'm wondering whether there is a gentle way let application get the error and remind customer kindly.

the following is the sample code.

int main() { zmq::context_t zmq_ctx(1); zmq::socket_t zmq_socket(zmq_ctx, ZMQ_REQ);

try {
    zmq_socket.connect("tcp://192.168.1.160:5000"); 

    std::string message = "Hello, World";
    zmq::message_t sock_msg(message.length());
    memcpy(sock_msg.data(), message.c_str(), message.length());

    zmq_socket.send(sock_msg);  // error happens 
}
catch (zmq::error_t e)
{
    printf("error happens in ZeroMQ: %s\n", e.what());
}

}

bluca commented 7 years ago

I'm not a Windows expert but it's the TCP connect system call that is failing with permission denied, so you'll want to check your environment (and the windows docs to see what that means)

wenjians commented 7 years ago

thanks a lot for your reply.

I wrote a simple TCP client and block in firewall as well, WinSocket can return error and application can report error accordingly, which is synchronous.

It might not easy for ZeroMQ since ZeroMQ does those in background thread and is asynchronous, but I'm wondering is it possible provide an option to monitor via zeromonitoring, application then can provide some customized friend error report to final user (most of them are nervous about such exception, which looks like application are crash.