crow icon indicating copy to clipboard operation
crow copied to clipboard

Crash using web sockets over https

Open perchits opened this issue 8 years ago • 4 comments

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 avatar Nov 07 '16 18:11 perchits

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.

perchits avatar Nov 07 '16 19:11 perchits

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

mengbieting avatar Jan 21 '19 01:01 mengbieting

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.

perchits avatar Jan 21 '19 12:01 perchits

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

mengbieting avatar Jan 23 '19 02:01 mengbieting