facebook / wangle

Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.
Apache License 2.0
3.04k stars 535 forks source link

transportInactive behaviour #143

Closed hayleyjames closed 5 years ago

hayleyjames commented 5 years ago

Environment: WSL Ubuntu for Windows Wangle version: v2018.11.05.00

My HandlerAdapter gets the transportActive notification but transportInactive is never called when the client terminates. readEOF gets called when the socket is closed. Should transportInactive automatically be invoked or is there an extra step I need to do myself?

Minor note: The BootstrapTest failed when running "ctest"

Handler code:

void SessionHandler::read(Context *ctx, std::unique_ptr<Packet> msg) {
    if (msg->ID() == 0) {
        auto packet = (ProxyJoinPacket*) msg.get();
    }
}

void SessionHandler::readException(Context *ctx,
                                   folly::exception_wrapper e) {
    std::cout << e.get_exception()->what() << std::endl;
}

void SessionHandler::transportActive(Context *ctx) {
    std::cout << "Transport active" << std::endl;
    Handler::transportActive(ctx);
}

void SessionHandler::transportInactive(Context *ctx) {
    std::cout << "Transport inactive" << std::endl;
    Handler::transportInactive(ctx);
}

void SessionHandler::readEOF(Context *ctx) {
    std::cout << "EOF" << std::endl;
    Handler::readEOF(ctx);
}

Client code (golang):

func main() {
        conn, err := net.Dial("tcp", "localhost:8080")
        if err != nil {
            panic(err)
        }

        buf := bytes.NewBuffer(nil)

        id := uint16(0)

        binary.Write(buf, binary.BigEndian, &id)

        uuid := "test"
        uuidLen := uint32(len(uuid))

        binary.Write(buf, binary.BigEndian, &uuidLen)

        buf.Write([]byte(uuid))

        write(conn, buf)

        panic(conn.Close())
}

This is what I get from my log statements:

Transport active
EOF
timeout

Thanks

hayleyjames commented 5 years ago

The answer to this question is in issue #54.