Giter Club home page Giter Club logo

Comments (6)

iyfedorov avatar iyfedorov commented on July 4, 2024

It can be helpful: i got like it problem with ReadStream.handler

val resp = req.send(Buffer.buffer(query.body.readAllBytes())).await()
resp.endHandler {
    println("CLOSED")
    respCh.close()
}
resp.exceptionHandler {
    it.printStackTrace()
}
resp.handler {
    println(it.getString(0, 10) +"..."+ it.getString(it.length()-10, it.length()))
}  
=====START RECEIVE=====
\n purus S...citudin er
os. Donec ...:00:00 AM\
"} ], \"ip...e\": \"app
lication/v...:"^1[./0-9
$","profil...33030]}]}}
CLOSED

But when i remove .await() from send call and use Fututre.onSuccess() - i get normal response all time

req.send(Buffer.buffer(query.body.readAllBytes())).onSuccess { resp ->
    resp.endHandler {
        println("CLOSED")
    }
    resp.exceptionHandler {
      it.printStackTrace()
    }
    resp.handler {
        println(it.getString(0, 10) +"..."+ it.getString(it.length()-10, it.length()))
    }
}
{"took":23...psum primi
s in fauci...","_id":"2
201756-2-0...ue dictum,
 efficitur...oncus vari
us. Aenean...uster":"te
st","sub_c...dimentum d
ui rutrum ...tricies, a
t vehicula...,\"connect
ion_data\"..., hendreri
t vestibul...68020]}]}}
CLOSED

from vertx-lang-kotlin.

iyfedorov avatar iyfedorov commented on July 4, 2024

Experimentally i found solution for my case :

suspend fun Future<HttpClientResponse>.await(): HttpClientResponse = when {
        succeeded() -> result().pause() <--- solution
        failed() -> throw cause()
        else -> suspendCancellableCoroutine { cont: CancellableContinuation<HttpClientResponse> ->
            onComplete { asyncResult ->
                if (asyncResult.succeeded()) cont.resume(asyncResult.result().pause()) <--- solution
                else cont.resumeWithException(asyncResult.cause())
            }
        }
}

i call HttpClientResponse.pause() immediately after taken the result. Between getting the HttpClientResponse and processing response batches i call HttpClientResponse.statusCode(). Can it invoke reading first batch without any handlers?

from vertx-lang-kotlin.

vietj avatar vietj commented on July 4, 2024

is there a bug we should fix ?

from vertx-lang-kotlin.

vietj avatar vietj commented on July 4, 2024

can you provide a reproducer project please ?

from vertx-lang-kotlin.

iyfedorov avatar iyfedorov commented on July 4, 2024

Hi, sorry, i missed github notification letter. I will prepare reproducer project when i get some free time. But now i think that problem in some specific elasticsearch response details (like a long warning header with text or chunked content-encoding).

from vertx-lang-kotlin.

tsegismont avatar tsegismont commented on July 4, 2024

Please reopen if you can provide a reproducer.

from vertx-lang-kotlin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.