Skip to content

in version 2.1 there is a bug need following correction #452

Description

@pkgvrpdm

need this patch in file sio_client_impl.cpp in function void client_impl::connect_impl(const string& uri, const string& queryString)
line number 225-226
// If a resource path was included in the URI, use that, otherwise
// use the default /socket.io/.
const std::string path(uo.get_resource() == "/" ? "/socket.io/" : uo.get_resource());

ss<<":"<<uo.get_port()<<path<<"?EIO=3&transport=websocket";

//ss<<":"<<uo.get_port()<<"/socket.io/?EIO=3&transport=websocket";

corrected code is below please someone push this in version 2.1 :

void client_impl::connect_impl(const string& uri, const string& queryString)
{
    do{
        websocketpp::uri uo(uri);
        ostringstream ss;

#if SIO_TLS
ss<<"wss://";
#else
ss<<"ws://";
#endif
const std::string host(uo.get_host());
// As per RFC2732, literal IPv6 address should be enclosed in "[" and "]".
if(host.find(':')!=std::string::npos){
ss<<"["<<uo.get_host()<<"]";
} else {
ss<<uo.get_host();
}
// If a resource path was included in the URI, use that, otherwise
// use the default /socket.io/.
const std::string path(uo.get_resource() == "/" ? "/socket.io/" : uo.get_resource());

        ss<<":"<<uo.get_port()<<path<<"?EIO=3&transport=websocket";
        
        //ss<<":"<<uo.get_port()<<"/socket.io/?EIO=3&transport=websocket";
        if(m_sid.size()>0){
            ss<<"&sid="<<m_sid;
        }
        ss<<"&t="<<time(NULL)<<queryString;
        lib::error_code ec;
        client_type::connection_ptr con = m_client.get_connection(ss.str(), ec);
        if (ec) {
            m_client.get_alog().write(websocketpp::log::alevel::app,
                                      "Get Connection Error: "+ec.message());
            break;
        }

        for( auto&& header: m_http_headers ) {
            con->replace_header(header.first, header.second);
        }

        m_client.connect(con);
        return;
    }
    while(0);
    if(m_fail_listener)
    {
        m_fail_listener();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions