Comments (10)
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.
Can you please paste the code that's throwing the exception? Including the target URL that you're trying to request.
from unirest-java.
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.
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.
Yeah, I was on the newest version with all updated dependancies
from unirest-java.
I've just pushed a fix on version 1.3.1 you can try to see if it's fixed now.
from unirest-java.
@Asperous Any news on this issue?
from unirest-java.
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.
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.
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)
- Small issue on Upgrade.md that prevents dependency installation HOT 1
- 4.0.4 isn't on the maven repository. HOT 1
- UnirestInstance.request() Method behaves differently than expected. HOT 3
- Configure custom retry behavior HOT 12
- Describe configuring concurrency in v4 HOT 1
- MockResponse does not work with Unirest 4 anymore HOT 7
- connectionTTL configuration ignored HOT 5
- Low level interceptor with shared context HOT 10
- bug query get with version 4 HOT 5
- Jackson MismatchedInputException for successful response with no body, after migrating to Unirest 4 HOT 2
- Automatic Retries not being used HOT 2
- MockClient: allow fine grained request verification or "un-expected" routes HOT 2
- Request cancellation (such as download cancellation) HOT 2
- Can't turn auto retries standard on HOT 10
- Incorrect Unirest version in README.md HOT 1
- Incorrect link to Interceptor file HOT 1
- Supported windows versions
- Configured HttpClient.Version ignored HOT 10
- MockClient: Mocking same route with different methods only invokes first registered/expected mocking response HOT 2
- multipart/form-data POST is missing content types HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unirest-java.