ipkn / crow

Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)
BSD 3-Clause "New" or "Revised" License
7.47k stars 888 forks source link

Crash using web sockets over https #187

Open perchits opened 7 years ago

perchits commented 7 years ago

Trying to combine ssl and websocket examples using VS2015 I've got a crash in SSLAdaptor::is_open() at the moment of opening the connection. After some examination I found out that SSLAdaptor::ssl_socket_ is nullptr. It happens in Connection::handle() when calling: handler_->handle_upgrade(req, res, std::move(adaptor_)); and then adaptor_ is being accessed in lambda expression in Connection::do_read(): if (ret && adaptor_.is_open()) Is there any working example how to make websocket connection over https? Thank you.

perchits commented 7 years ago

As a temporary workaround I have changed SSLAdaptor::ssl_socket_ from unique_ptr to to shared_ptr and defined move constructor for SSLAdaptor like this:

SSLAdaptor(SSLAdaptor&& other) : ssl_socket_(other.ssl_socket_)
{
}

So it works for me for now, but I have not examined all consequences yet.

mengbieting commented 5 years ago

Oh, my god, I also encountered this problem, which bothered me for two days or so, thank you very much for solving my problem.

perchits commented 5 years ago

You are welcome. You should also keep in mind that Crow has many problems in other aspects, one of them is lack of decent multi-threading support. Unfortunately this project seems to be abandoned so I had to move to Boost.Beast. It costed me some amount of time but it's worth it.

mengbieting commented 5 years ago

Ok, I understand, thank you very much for your guidance.