Skip to content
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

handhake error: http header is not a websocket upgrade #28

Closed
sergluka opened this issue Feb 23, 2018 · 3 comments
Closed

handhake error: http header is not a websocket upgrade #28

sergluka opened this issue Feb 23, 2018 · 3 comments

Comments

@sergluka
Copy link
Contributor

Got error upgrading to WebSocket at connect to WampRouter from https://github.com/Matthias247/jawampa.
Since other client is able to connect to this router, I presume it's a wampcc issue.

connect.log
connect.pcap.zip

My code:

void Client::connect_async()
{
    m_connection_open = true;

    while (true) {
        if (!m_connection_open) {
            return;
        }

        const auto remote = m_config.router.remote;
        LOG_INFO("Connecting to %s:%hu, realm=%s ...", remote.host, remote.port, REALM);

        const auto timeout = std::chrono::system_clock::now() + remote.timeout;

        m_socket = std::make_unique<wampcc::tcp_socket>(&m_kernel);
        auto status = m_socket->connect(remote.host, remote.port).wait_until(timeout);

        switch (status) {
            case std::future_status::timeout:
                LOG_ERROR("Connection timeout (%Lds)", m_config.router.remote.timeout.count());
                break;
            case std::future_status::ready:
                LOG_INFO_MSG("Connected");
                break;
            case std::future_status::deferred:
                LOG_WARN_MSG("Connection is deferred");
                break;
        }

        if (!m_connection_open) {
            return;
        }

        if (!m_socket->is_connected()) {
            LOG_ERROR("Connection failed. Retry in %Lds", remote.timeout.count());
            std::this_thread::sleep_until(timeout);
            continue;
        }

        break;
    }

    m_session = wamp_session::create<websocket_protocol>(&m_kernel, std::move(m_socket),
                                                         [this](wamp_session & session, bool is_open) {
                                                             on_status_change(session, is_open);
                                                         });
    if (!hello(REALM)) {
        LOG_ERROR_MSG("Authorization error");
        return;
    }
    LOG_INFO("Attached to a realm '%s'", REALM);
}

@sergluka
Copy link
Contributor Author

Most likely root cause is that response header fields are in lower case, but RFC 2616 said they have to be case-insensitive.

@darrenjs
Copy link
Owner

Thanks for this. I think your assessment it right. I'll put in a fix.

@darrenjs
Copy link
Owner

fixed in 76180a0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants