-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No able to get the full path while running Async SSL websock code. #2912
Comments
You need to do a "reverse DNS lookup" on the IP if you want to get the name. |
Hi @vinniefalco , I tried using reverse DNS lookup but it is giving IP and port only. I need to get the full endpoint because I am doing my other tasks such as no same url path channel allowed etc, for that I need to get the complete endpoint. Example:"wss://server-name.com/username1/..". The major part is from "/username1/..". |
First, you need to read the initial HTTP upgrade request (just like a regular http request) and inspect the request target. Then, use this overload of |
Hi @ashtum, I am taking the chat-multi code example(/example/websocket/server/chat-multi) and in that I have replaced the listener.cpp, websocket_session.cpp and http_session.cpp with websocket_server_async_ssl.cpp and http_server_async_ssl.cpp because I want to test with SSL but the issue is that the https part is working fine but if we sending the "wss" connection then it is going to websocket_session::on_run() function and not able to do handshake(in websocket_session::on_handshake) function. My observations is that during the opening of connection it is going to http_session::on-run and from there it is going to listener::do_accept and then from there to http_session::on_handshake function and then if it is a websocket upgrade then it proceed accordingly. It should go to listener::do_accept and then to websocket_session::on_handshake and then to websocket_session::on_accept, but it is not going. Can you please help me with the same. I even tried by doing ssl handshake only in https and not in websocket part but it is not even accepting the wss connection. |
It's difficult to determine the issue without seeing the code. Please check if the client successfully completes the SSL handshake. If you receive the HTTP upgrade request separately, use this overload of websocket::stream::async_accept and provide the initial upgrade request. |
Hi @ashtum, I have made a sample code but here it is not possible to send all the files(.hpp and .cpp), so can you please share you email ID where I will send you the code. |
If the issue is the number of files, you can create a gist. If the issue is privacy, you can send me at ashtumashtum@gmail.com. |
Thankyou @ashtum, will share you through email. |
You discard the request in this line: template<class Body, class Allocator> void websocket_session::run(http::request<Body, http::basic_fields<Allocator>> req, int timeout_value)
{
std::cout<<"websocket session run"<<"\n";
net::dispatch(ws_.get_executor(), beast::bind_front_handler( &websocket_session::on_run, shared_from_this()));
} You need to use this overload of websocket::stream::async_accept and provide the initial upgrade request. |
Hi @ashtum, I tried changing by discarding the below code and overload by using async_accept but I am not able to do it correctly. Can you please help me with this part, I am not able to understand properly. |
Hii all, https://gist.github.com/shivank1111/3b5864811a8a1e819cc7c161b63aa741 |
You need to pass the There is more issue in your code, like here you try to do another ssl handshake: void websocket_session::on_run()
{
std::cout<<"Websocket session on_run"<<"\n";
beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30));
// Perform the SSL handshake
ws_.next_layer().async_handshake( ssl::stream_base::server, beast::bind_front_handler( &websocket_session::on_handshake, shared_from_this()));
I would recommend begin with advanced_server_flex and modify it to your need. |
Okay @ashtum, thanks for the help. I will begin from advanced_server_flex and the proceed accordingly. |
Version - 1.83
I am not able to get the endpoint(Full path of the connection- like wss://server-name.com/username1/..). I am trying the get the full endpoint in on_accept class of listener.cpp and during websocket handshake.(In on_run() function) but still not successful in getting.
I am only getting the IP and port from which the connection came.
Kindly help me with the same.
I am using the basic example of websocket_server_async_ssl.cpp and also attaching the code.
The text was updated successfully, but these errors were encountered: