Git Product home page Git Product logo

Comments (10)

andychase avatar andychase commented on July 28, 2024

Also, apparently async client silently swallows exceptions? (and puts them in a log somewhere I assume). This is really annoying behavior that took me awhile to track down.

This method using straight asynchttpclient seems to work with https/ssl:

val httpClient = HttpAsyncClients.custom.setSSLIOSessionFactory(SSLIOSessionFactory.getDefaultStrategy).build
httpClient.start()
val request: HttpGet = new HttpGet(url)
httpClient.execute(request, callback)

from unirest-java.

subnetmarco avatar subnetmarco commented on July 28, 2024

Can you please paste the code that's throwing the exception? Including the target URL that you're trying to request.

from unirest-java.

andychase avatar andychase commented on July 28, 2024

The callbacks aren't called in this example. If I change HttpReponse[JsonNode] to HttpReponse[String] then completed is called, but response.getBody is a bunch of garbage (I'm assuming encrypted response). The url works in Chrome and returned the correct json.

Warning: Scala

class BlockchainPayments(private val token: String, private val password: String, val limit: Float, var current: Int = 0) extends PaymentProvider {
    val endpoint:String = s"https://blockchain.info/merchant/$token/"

    def sendPayment(address: String, amount: Float, reply: (String => Unit)) {
        val satoshi = (amount * 100000000).toLong
        Unirest.get(endpoint ++ s"payment?password=$password&to=$address&amount=$satoshi").asJsonAsync(new Callback[JsonNode]() {
            def failed(e: UnirestException) {
                println("The request has failed")
            }

            def completed(response: HttpResponse[JsonNode]) {
                val json = response.getBody
                if (json.getObject.has("message")) {
                    json.getObject.get("message") match {
                        case message:String =>
                            reply(message)
                    }
                }
                if (json.getObject.has("error")) {
                    json.getObject.get("error") match {
                        case error:String =>
                            reply(error)
                    }
                }
            }

            def cancelled() {
                println("The request has been cancelled")
            }
        })
    }
}

from unirest-java.

subnetmarco avatar subnetmarco commented on July 28, 2024

I think this is a bug. Can you please try to update Unirest to version 1.3.1 ?

Remember to also update it's dependencies (https://github.com/Mashape/unirest-java#installing)

from unirest-java.

andychase avatar andychase commented on July 28, 2024

Yeah, I was on the newest version with all updated dependancies

from unirest-java.

subnetmarco avatar subnetmarco commented on July 28, 2024

I've just pushed a fix on version 1.3.1 you can try to see if it's fixed now.

from unirest-java.

subnetmarco avatar subnetmarco commented on July 28, 2024

@Asperous Any news on this issue?

from unirest-java.

andychase avatar andychase commented on July 28, 2024

Yeah, I got Exception in thread "InterruptConnectionKeepAlive" java.lang.NoSuchMethodError: org.apache.http.impl.nio.client.CloseableHttpAsyncClient.isRunning()

at com.mashape.unirest.http.HttpClientHelper.requestAsync(HttpClientHelper.java:84) at com.mashape.unirest.request.BaseRequest.asJsonAsync(BaseRequest.java:72)

from unirest-java.

andychase avatar andychase commented on July 28, 2024

I'm not really able to test this further unfortunately, since I am pretty satisfied with the working solution I got from apache's asynchttpclient, perhaps it was a library configuration problem.

Thanks for your concern and best wishes with the library!

from unirest-java.

subnetmarco avatar subnetmarco commented on July 28, 2024

I think the Exception is being thrown due to an old version of the httpasyncclient dependency, if you update it toversion 4.0 should work.

from unirest-java.

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.