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

EOF error when calling http::write after accepting connection in the server #2751

Closed
dellarocca99 opened this issue Oct 18, 2023 · 3 comments

Comments

@dellarocca99
Copy link

Hi @vinniefalco !

I'm working on a server that uses an old version of Beast, with Boost 1.59.0.
The content of version.hpp is the following:

//
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef BEAST_VERSION_HPP
#define BEAST_VERSION_HPP

// follows http://semver.org

//  BEAST_VERSION % 100 is the patch level
//  BEAST_VERSION / 100 % 1000 is the minor version
//  BEAST_VERSION / 100000 is the major version
//
#define BEAST_VERSION 100000

#define BEAST_VERSION_STRING "1.0.0-b13"

#endif

This server was working fine with an nw.js browser. However, I changed this nw.js browser to a newer one, and now I'm facing the following error: when I accept the connection from the client, it crashes with the error "End of File".

To be more specific, it throws the error when execution reaches the line 538 of write.ipp. The method is "write" and it looks like this:

template<class SyncWriteStream,
    bool isRequest, class Body, class Headers>
void
write(SyncWriteStream& stream,
    message_v1<isRequest, Body, Headers> const& msg,
        boost::system::error_code& ec)
{
    static_assert(is_SyncWriteStream<SyncWriteStream>::value,
        "SyncWriteStream requirements not met");
    static_assert(is_WritableBody<Body>::value,
        "WritableBody requirements not met");
    detail::write_preparation<isRequest, Body, Headers> wp(msg);
    wp.init(ec);
    if(ec)
        return;
    std::mutex m;
    std::condition_variable cv;
    bool ready = false;
    resume_context resume{
        [&]
        {
            std::lock_guard<std::mutex> lock(m);
            ready = true;
            cv.notify_one();
        }};
    auto copy = resume;
    boost::tribool result = wp.w(std::move(copy),
        ec, detail::writef0_lambda<SyncWriteStream,
            decltype(wp.sb)>{stream, wp.sb, wp.chunked, ec});
    if(ec)
        return;
    if(boost::indeterminate(result))
    {
        copy = resume;
        {
            std::unique_lock<std::mutex> lock(m);
            cv.wait(lock, [&]{ return ready; });
            ready = false;
        }
        boost::asio::write(stream, wp.sb.data(), ec);
        if(ec)
            return;
        result = false;
    }
    wp.sb.consume(wp.sb.size());
    if(! result)
    {
        for(;;)
        {
            result = wp.w(std::move(copy), ec,
                detail::writef_lambda<SyncWriteStream>{
                    stream, wp.chunked, ec});
            if(ec)
                return;
            if(result)
                break;
            if(! result)
                continue;
            copy = resume;
            std::unique_lock<std::mutex> lock(m);
            cv.wait(lock, [&]{ return ready; });
            ready = false;
        }
    }
    if(wp.chunked)
    {
        // VFALCO Unfortunately the current interface to the
        //        Writer concept prevents us from using coalescing the
        //        final body chunk with the final chunk delimiter.
        //
        // write final chunk
        boost::asio::write(stream, detail::chunk_encode_final(), ec);
        if(ec)
            return;
    }
    if(wp.close)
    {
        // VFALCO TODO Decide on an error code
        ec = boost::asio::error::eof;
    }
}

It breaks when wp.close is true and then it throws the error.
I'm using VS2017 and MSVC v140. I'm compiling Beast code with my project as it is not present in Boost 1.59.0

Thanks in advance!!!

@fpelliccioni
Copy link
Collaborator

Hello,

From the provided version.hpp, it's challenging to identify the exact Beast version, but it appears you're using an older one. Linking directly to the specific Beast files on GitHub can help us pinpoint the issue more efficiently.

To further investigate and reproduce the problem, please provide:

  • Complete platform details.
  • Source code of the Beast server application.
  • Source code of the client-side JavaScript.
  • Compilation method for the C++ code.
  • Execution method for the JS code.

Additionally, I recommend updating to a more recent version of Beast as a preliminary step, as this might resolve the issue and offer additional improvements.

@vinniefalco
Copy link
Member

1.0.0-b13 is unsupported

@fpelliccioni I don't think any of that information is going to help us

@fpelliccioni
Copy link
Collaborator

Good to know, thanks.
So @dellarocca99, I have to close the issue becase the version you are using is unsupported.

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

3 participants