async-http-client
Asynchronous Http and WebSocket Client library for Java
I think I've managed to make a test that shows this problem repeatably, at least on my system. This question relates to HttpClient being used for a bad endpoint (nonexistant endpoint, the target is down).
The problem is that the number of completed tasks falls short of the total, usually by about a few. I don't mind requests not working, but this just results in the app just hanging there when the results are awaited.
I get the following result form the test code below:
Elapsed: 237.2009884 seconds.
Tasks in batch array: 8000 Completed Tasks : 7993
If i set batchsize to 8 instead of 8000, it completes. For 8000 it jams on the WhenAll .
I wonder if other people get the same result, if I am doing something wrong, and if this appears to be a bug.
using System;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace CustomArrayTesting
{
/// <summary>
/// Problem: a large batch of async http requests is done in a loop using HttpClient, and a few of them never complete
/// </summary>
class ProgramTestHttpClient
{
static readonly int batchSize = 8000; //large batch size brings about the problem
static readonly Uri Target = new Uri("http://localhost:8080/BadAddress");
static TimeSpan httpClientTimeout = TimeSpan.FromSeconds(3); // short Timeout seems to bring about the problem.
/// <summary>
/// Sends off a bunch of async httpRequests using a loop, and then waits for the batch of requests to finish.
/// I installed asp.net web api client libraries Nuget package.
/// </summary>
static void Main(String[] args)
{
httpClient.Timeout = httpClientTimeout;
stopWatch = new Stopwatch();
stopWatch.Start();
// this timer updates the screen with the number of completed tasks in the batch (See timerAction method bellow Main)
TimerCallback _timerAction = timerAction;
TimerCallback _resetTimer = ResetTimer;
TimerCallback _timerCallback = _timerAction + _resetTimer;
timer = new Timer(_timerCallback, null, TimeSpan.FromSeconds(1), Timeout.InfiniteTimeSpan);
//
for (int i = 0; i < batchSize; i++)
{
Task<HttpResponseMessage> _response = httpClient.PostAsJsonAsync<Object>(Target, new Object());//WatchRequestBody()
Batch[i] = _response;
}
try
{
Task.WhenAll(Batch).Wait();
}
catch (Exception ex)
{
}
timer.Dispose();
timerAction(null);
stopWatch.Stop();
Console.WriteLine("Done");
Console.ReadLine();
}
static readonly TimeSpan timerRepeat = TimeSpan.FromSeconds(1);
static readonly HttpClient httpClient = new HttpClient();
static Stopwatch stopWatch;
static System.Threading.Timer timer;
static readonly Task[] Batch = new Task[batchSize];
static void timerAction(Object state)
{
Console.Clear();
Console.WriteLine("Elapsed: {0} seconds.", stopWatch.Elapsed.TotalSeconds);
var _tasks = from _task in Batch where _task != null select _task;
int _tasksCount = _tasks.Count();
var _completedTasks = from __task in _tasks where __task.IsCompleted select __task;
int _completedTasksCount = _completedTasks.Count();
Console.WriteLine("Tasks in batch array: {0} Completed Tasks : {1} ", _tasksCount, _completedTasksCount);
}
static void ResetTimer(Object state)
{
timer.Change(timerRepeat, Timeout.InfiniteTimeSpan);
}
}
}
Sometimes it just crashes before finishing with an Access Violation unhandled exception. The call stack just says:
> mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode = 1225, uint numBytes = 0, System.Threading.NativeOverlapped* pOVERLAP = 0x08b38b98)
[Native to Managed Transition]
kernel32.dll!@BaseThreadInitThunk@12()
ntdll.dll!___RtlUserThreadStart@8()
ntdll.dll!__RtlUserThreadStart@8()
Most of the time it doesn't crash but just never finishes waiting on the whenall. In any case the following first chance exceptions are thrown for each request:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.AggregateException' occurred in mscorlib.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
I made the debugger stop on the Object disposed exception, and got this call stack:
> System.dll!System.Net.Sockets.NetworkStream.UnsafeBeginWrite(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) + 0x136 bytes
System.dll!System.Net.PooledStream.UnsafeBeginWrite(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) + 0x19 bytes
System.dll!System.Net.ConnectStream.WriteHeaders(bool async = true) + 0x105 bytes
System.dll!System.Net.HttpWebRequest.EndSubmitRequest() + 0x8a bytes
System.dll!System.Net.HttpWebRequest.SetRequestSubmitDone(System.Net.ConnectStream submitStream) + 0x11d bytes
System.dll!System.Net.Connection.CompleteConnection(bool async, System.Net.HttpWebRequest request = {System.Net.HttpWebRequest}) + 0x16c bytes
System.dll!System.Net.Connection.CompleteConnectionWrapper(object request, object state) + 0x4e bytes
System.dll!System.Net.PooledStream.ConnectionCallback(object owningObject, System.Exception e, System.Net.Sockets.Socket socket, System.Net.IPAddress address) + 0xf0 bytes
System.dll!System.Net.ServicePoint.ConnectSocketCallback(System.IAsyncResult asyncResult) + 0xe6 bytes
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) + 0x65 bytes
System.dll!System.Net.ContextAwareResult.Complete(System.IntPtr userToken) + 0x92 bytes
System.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken) + 0xa6 bytes
System.dll!System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) + 0x98 bytes
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) + 0x6e bytes
[Native to Managed Transition]
The exception message was:
{"Cannot access a disposed object.\r\nObject name: 'System.Net.Sockets.NetworkStream'."} System.Exception {System.ObjectDisposedException}
Notice the relationship to that unhandled access violation exception that I rarely see.
So, it seems that HttpClient is not robust for when the target is down. I am doing this on windows 7 32 by the way.
Source: (StackOverflow)
I am facing some problems when using the HttpClient class to access to a Delicious API. I have the following code:
try
{
const string uriSources = "https://api.del.icio.us/v1/tags/bundles/all?private={myKey}";
using (var handler = new HttpClientHandler { Credentials = new
NetworkCredential("MyUSER", "MyPASS") })
{
using (var client = new HttpClient(handler))
{
var result = await client.GetStringAsync(uriSources);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "ERROR...", MessageBoxButton.OK);
}
When running the code above I am getting the following: Response status code does not indicate success: 401 (Unauthorized).
So, how could I get this work? Is it possible?
Thanks in advance
Regards!
Source: (StackOverflow)
I'm hitting deadlock even after using ConfigureAwait(false)
, below is the sample code.
As per the sample http://blog.stephencleary.com/2012/02/async-and-await.html (#Avoding Context), this should not have hit dead lock.
This is my class:
public class ProjectsRetriever
{
public string GetProjects()
{
...
var projects = this.GetProjects(uri).Result;
...
...
}
private async Task<IEnumerable<Project>> GetProjects(Uri uri)
{
return await this.projectSystem.GetProjects(uri, Constants.UserName).ConfigureAwait(false);
}
}
This class is from a shared library:
public class ProjectSystem
{
public async Task<IEnumerable<Project>> GetProjects(Uri uri, string userName)
{
var projectClient = this.GetHttpClient<ProjectHttpClient>(uri);
var projects = await projectClient.GetProjects();
// code here is never hit
...
}
Works if I add ConfigureAwait(false) to await call in shared library, where HttpClient call is made:
public class ProjectSystem
{
public async Task<IEnumerable<Project>> GetProjects(Uri uri, string userName)
{
var projectClient = this.GetHttpClient<ProjectHttpClient>(uri);
var projects = await projectClient.GetProjects().ConfigureAwait(false);
// no deadlock, resumes in a new thread.
...
}
I've been going through all blogs found, only difference I find is ConfigureAwait(false) works when used with httpClient.AsyncApi() call!?
Please help clarify!!!
Source: (StackOverflow)
Using the AsyncHttpClient
with Netty
provider will prevent the main program to terminate when we execute an asynchronous request.
For instance, the following program terminates after the println
, or not, depending on whether the provider is JDKAsyncHttpProvider
or NettyAsyncHttpProvider
:
public class Program {
public static CompletableFuture<Response> getDataAsync(String uri) {
final AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
final CompletableFuture<Response> promise = new CompletableFuture<>();
asyncHttpClient
.prepareGet(uri)
.execute(new AsyncCompletionHandler<Response>(){
@Override
public Response onCompleted(Response resp) throws Exception {
promise.complete(resp);
asyncHttpClient.close(); // ??? Is this correct ????
return resp;
}
});
return promise;
}
public static void main(String [] args) throws Exception {
final String uri = "…";
System.out.println(getDataAsync(uri).get());
}
}
About the AsynHttpClient
the documentation states:
AHC is an abstraction layer that can work on top of the bare JDK, Netty and Grizzly. Note that the JDK implementation is very limited and you should REALLY use the other real providers.
To use AsyncHttpClient with Netty we just need to include the corresponding library in the java class path. So, we may run the previous Program
with one of the following class path configurations to use Netty, or not:
-cp .;async-http-client-1.9.24.jar;netty-3.10.3.Final.jar;slf4j-api-1.7.12.jar
will use NettyAsyncHttpProvider
-cp .;async-http-client-1.9.24.jar;slf4j-api-1.7.12.jar
will use JDKAsyncHttpProvider
What else should we do to use Netty provider correctly? For instance, I am closing the AsyncHttpClient
in AsyncCompletionHandler
. Is that correct?
Is there any configuration to change the observed behavior?
Source: (StackOverflow)
I got app which does some networking based on user activity. Usual payload sent by the app is 100-200 bytes so basically no heavy lifting tasks. These tasks are usually working w/o any problems (statistically 99,9% or requests are fine), but aside from these networking activities, my app is also sending heartbeat back to our servers (which are on Amazon's EC2 (us-east1-d if that would matter)). Heartbeat is sent each 10 seconds as ordinary POST request over HTTPS - and this is what is not really working for me as the failure rate is much higher than observed with normal network activities - during my recent 7 hour test 25% of heartbeat requests failed (but I saw even 35% drops) and it usually keeps at that rate. When I disable SSL then error rate stays on my test device at 8% percent. This probably would not be that big issue really if these failures would fall into any pattern (i.e. each 4th etc which could mean some rate based filtering, or would fail close to each full hour or day which could mean kind of request cap is set somewhere). But nothing like this happens - sometimes 10-15 request can fail in a row, and this is bad for heartbeat. Additionally, to make thing worse, at the moment I see requests failing I can connect to the server from the same device and this is working without problems). This issue happens on any supported version of Android (2.2+).
I use recent httpclientandroidlib to do the HTTP requests, so I started to suspect that lib to be a culprit so I switched to Android Asynchronous HTTP Client but it gave no change really. I am mostly getting Exceptions like:
NoHttpResponseException: The target server failed to respond The
target server failed to respond URL: https://xx.xx.xx.xx/heartbeat/
and for SSL enabled connections also:
javax.net.ssl.SSLException: Read error: ssl=0x784bc588: I/O error
during system call, Connection reset by peer Read error:
ssl=0x784bc588: I/O error during system call, Connection reset by peer
URL: https://xx.xx.xx.xx/heartbeat/
I basically would like to trace the culprit first, so knowing that the app is running over mobile networks mostly, I am open for any suggestion to how to proceed further with this problem as I am at the moment stuck a bit.
Source: (StackOverflow)
I'm trying to call PostAsync method using System.Net.Http.HttpClient from the Web API. I get the following error:
System.AggregateException "A task was canceled."
Task:
Id = 1, Status = System.Threading.Tasks.TaskStatus.Canceled, Method = "{null}", Result = "{Not yet computed}"
Code:
using (HttpClientHandler handler = new HttpClientHandler())
{
handler.Credentials = new NetworkCredential("MyUsername", "p@ssw0rd");
using (HttpClient client = new HttpClient(handler))
{
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("status", "Hello world"));
HttpContent content = new FormUrlEncodedContent(postData);
var responseTask = client.PostAsync(url, content).ContinueWith(
(postTask) =>
{
postTask.Result.EnsureSuccessStatusCode();
});
}
I assume the responseTask will force the method to run synchronously?
It's a WPF application, not ASP.NET.
Source: (StackOverflow)
Receiving a Gzipped response from an API, but Dispatch 0.9.5 doesn't appear to have any methods to decode the response. Any ideas?
Here's my current implementation, the println
only prints out string representations of bytes.
Http(
host("stream.gnip.com")
.secure
.addHeader("Accept-Encoding", "gzip")
/ gnipUrl
> as.stream.Lines(println))()
Tried to look at implementing my own handler, but not sure where to begin. Here's the relevant file for Lines
: https://github.com/dispatch/reboot/blob/master/core/src/main/scala/as/stream/lines.scala
Thanks!
Source: (StackOverflow)
I am using Spring Jersey framework. I want to implement waiting response to be returned to server while middleware is processing.
Sceniro:
Server A request to middle ware. Middleware server start processing on the request and request to another Server B.
While requesting Server B from middleware if the response takes longer time than 30 seconds middleware should send Response-A as "request in progress"
- After receiving response from server B it should again send response B to Server A.
- if Server B responds in 30 seconds than Response - A will be neglected.
Code Snippets:
EndPoint (Controller)
@Path("/")
@GET
public Object getResponse(@Context HttpServletRequest request,SomeDataWrapper someData)
{
// Server - A call this method
return service.getResponse(someData);
}
Service Method : (That will call Server B)
public Object getResponse(SomeDataWrapper someData){
// Code to call another Server B
Object response = callServerB();
// How to achieve threading mechanism here to response back to server a for waiting
return response;
}
Related Model classes (Wrappers)
public class SomeDataWrapper{
private long id;
private String data;
//getter setters goes here
}
public class WaitResponseWrapper{
private long id;
private String waitingStatus;
private String someText;
//getter setters goes here
}
How to achieve Threading mechanism in service so that the response can not be swallowed? much appreciated with code snippet for threading mechanism. Thank you
Source: (StackOverflow)
I'm constructing an AsyncHttpClient
like this:
public AsyncHttpClient getAsyncHttpClient() {
AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
.setProxyServer(makeProxyServer())
.setRequestTimeoutInMs((int) Duration.create(ASYNC_HTTP_REQUEST_TIMEOUT_MIN, TimeUnit.MINUTES).toMillis())
.build();
return new AsyncHttpClient(new NettyAsyncHttpProvider(config), config);
}
This gets called once at startup, and then the return value is passed around and used in various places. makeProxyServer()
is my own function to take my proxy settings an return a ProxyServer
object. What I need to do is be able to change the proxy server settings and then recreate the AsyncHttpClient
object. But, I don't know how to shut it down cleanly. A bit of searching on leads me to believe that close()
isn't gracefull. I'm worried about spinning up a whole new executor and set of threads every time the proxy settings change. This won't be often, but my application is very long-running.
I know I can use RequestBuilder.setProxyServer()
for each request, but I'd like to have it set in one spot so that all callers of my asyncHttpClient
instance obey the system-wide proxy settings without each developer having to remember to do it.
What's the right way to re-configure or teardown and rebuild a Netty
-based AsyncHttpClient
?
Source: (StackOverflow)
I'm having trouble with some code I'm testing using AsyncHTTPClient. Here is the general config
this.config = (new AsyncHttpClientConfig.Builder())
.setAllowPoolingConnection(true)
.setAllowSslConnectionPool(true)
.addRequestFilter(new ThrottleRequestFilter(10))
.setMaximumConnectionsPerHost(20)
//.setMaximumConnectionsTotal(20)
.setRequestTimeoutInMs(100000)
.build();
this.client = new AsyncHttpClient(new NettyAsyncHttpProvider(config));
(Note that max connections is commented out because of some weird bug when using ThrottleRequestFilter, see here https://groups.google.com/forum/?fromgroups=#!topic/asynchttpclient/nEnQnPtCP2g)
Now here is some test code,
FileInputStream fstream = new FileInputStream("import.txt");
DataInputStream dstream = new DataInputStream(fstream);
BufferedReader reader = new BufferedReader(new InputStreamReader(dstream));
while ((line = reader.readLine()) != null) {
//Some code to build and create a request using the build function and then perform a GET operation. Request is built using Java's Future object from java.concurrent
}
When the import.txt file is less than 100 lines of simple text such as this
196 242 3 881250949
Everything works fine, all the requests go through and when you check the responses all is fine. Anything over 100 and I start getting timeouts and in cases of something like 1000+, I actually start running into permGen memory errors.
I thought the ThrottleRequestFilter is supposed to limit the max threads to 10 and process only 10 at a time. Why does it bomb out when the text file has more than 100+ lines?
I've also tried switching to using the Grizzly implementation but that also bombs out the same way. I'm beginning to suspect it's either the way I wrote the test code or Async HTTP Client actually has some issues when creating a high number of requests. If so, are there any other good async http clients for java?
Source: (StackOverflow)
I'm trying to create asynchronous rest call in Android using a library com.loopj.android.http.AsyncHttpClient
however, i'm unable to implement AsyncHttpResponseHandler's overridden methods because Android Studio cannot find an appropriate import for Header
class
How can I resolve the issue with the Header class not recognized by the Android Studio IDE?
public void onSuccess(int statusCode, Header[] headers, byte[] response) {
// called when response HTTP status is "200 OK"
}
I see that if I mouse over and click on the Header, I get the following message, but I don't know how to select one of the multiple choices in this menu (moving the mouse dismisses it)
Source: (StackOverflow)
I'm working on a new Windows Phone 8 app. I'm connecting to a webservice which returns valid json data. I'm using longlistselector to display the data. This works fine when i'm using the string json in GetAccountList(); but when receiving data from the DataServices class i'm getting the error "Cannot implicitly convert type 'System.Threading.Tasks.Task'to string". Don't know what goes wrong. Any help is welcome. Thanks!
DataServices.cs
public async static Task<string> GetRequest(string url)
{
HttpClient httpClient = new HttpClient();
await Task.Delay(250);
HttpResponseMessage response = await httpClient.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Debug.WriteLine(responseBody);
return await Task.Run(() => responseBody);
}
AccountViewModel.cs
public static List<AccountModel> GetAccountList()
{
string json = DataService.GetRequest(url);
//string json = @"{'accounts': [{'id': 1,'created': '2013-10-03T16:17:13+0200','name': 'account1 - test'},{'id': 2,'created': '2013-10-03T16:18:08+0200','name': 'account2'},{'id': 3,'created': '2013-10-04T13:23:23+0200','name': 'account3'}]}";
List<AccountModel> accountList = new List<AccountModel>();
var deserialized = JsonConvert.DeserializeObject<IDictionary<string, JArray>>(json);
JArray recordList = deserialized["accounts"];
foreach (JObject record in recordList)
{
accountList.Add(new AccountModel(record["name"].ToString(), record["id"].ToString()));
}
return accountList;
}
UPDATE: I changed it slightly and works like a charm now. Thanks for your help!
DataServices.cs
//GET REQUEST
public async static Task<string> GetAsync(string url)
{
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(url);
string content = await response.Content.ReadAsStringAsync();
return content;
}
AccountViewModel.cs
public async void LoadData()
{
this.Json = await DataService.GetAsync(url);
this.Accounts = GetAccounts(Json);
this.AccountList = GetAccountList(Accounts);
this.IsDataLoaded = true;
}
public static IList<AccountModel> GetAccounts(string json)
{
dynamic context = JObject.Parse(json);
JArray deserialized = (JArray)JsonConvert.DeserializeObject(context.results.ToString());
IList<AccountModel> accounts = deserialized.ToObject<IList<AccountModel>>();
return accounts;
}
public static List<AlphaKeyGroup<AccountModel>> GetAccountList(IList<AccountModel> Accounts)
{
List<AlphaKeyGroup<AccountModel>> accountList = AlphaKeyGroup<AccountModel>.CreateGroups(Accounts,
System.Threading.Thread.CurrentThread.CurrentUICulture,
(AccountModel s) => { return s.Name; }, true);
return accountList;
}
Source: (StackOverflow)
i'm trying to coding an android app that send some post values to a php file hosted at a dedicate server and store the array resoult
the code is this
HttpPost httppost;
DefaultHttpClient httpclient;
httppost = new HttpPost("http://IP/script.php");
HttpParams param = new BasicHttpParams();
param.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
// httppost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
HttpProtocolParams.setContentCharset(param, "UTF-8");
httpclient = new DefaultHttpClient(param);
ResponseHandler <String> res=new BasicResponseHandler();
List<NameValuePair> nameValuePairs;
nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("id","1"));
nameValuePairs.add(new BasicNameValuePair("api", "1"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Log.v("1",System.currentTimeMillis()+"");// Log to know the time diff
String result= httpclient.execute(httppost, res);
Log.v("2",System.currentTimeMillis()+""); // Log to know the time diff
this code waste about 2.5seconds (on 3G or WiFi) to send the post and get just "ok" string from server , even with good wifi this time down only to 2.2 / 2.0 seconds
I ran a simple Ajax sendpost script in my computer conected to internet through the same phone and 3G, it's take about .300ms to do the same stuff so ¿Same conection, same action, 2 seconds difference ?
///***UPDATE
I tried again my jquery script on my computer (with a mobile 3G+/HDSPA conection)
the average time response is about 250ms but always the first request up to 1.7secs, i tried to send posts with intervals of 30 seconds and i got 1.5 secs average time, then i tried to send a post with intervals of 2 seconds, the first was 1.41s and nexts 252ms
here you guys can view the chart: http://i46.tinypic.com/27zjl8n.jpg
This same test with cable conection (standard home DSL) offers always a fixed time response of ~170ms intervals regardless (not solid arguments here but IMHO maybe the first attempt is slightly slightly higher)
So there is something out (or wrong) severely affecting mobile conections in the first attempt, Any idea guys?
Source: (StackOverflow)
Below is the request header and response (100-continue) response from server after which connection is reset.
The server returns a 100-continue, but the client doesnt wait till its gets the 200OK and resets the connection. How do I make client wait till it gets 200OK.?
ContentType: application/json
Expect: 100-continue
Content-Length: 113365
Content-Type: multipart/form-data; boundary=gWa8t5W_OdBOuJ3bkZHMbn7-i56r_807wz6Q_qr
Connection: keep-alive
Accept: */*
User-Agent: xyz/abc
Response DefaultHttpResponse(chunked: false)
HTTP/1.1 100 Continue
2015-05-21 05:14:40,406 [DEBUG] - Unexpected I/O exception on channel [id: 0x732dfcd6, /10.28.211.80:55487 => ws.example.com/98.132.140.35:4080]
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_25]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_25]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_25] at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_25]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:470) ~[na:1.8.0_25]
at com.ning.http.client.multipart.MultipartUtils.writeBytesToChannel(MultipartUtils.java:130) ~[async-http-client-1.9.19.jar:na]
at com.ning.http.client.multipart.ByteArrayPart.write(ByteArrayPart.java:75) ~[async-http-client-1.9.19.jar:na]
at com.ning.http.client.multipart.MultipartBody.transferTo(MultipartBody.java:86) ~[async-http-client-1.9.19.jar:na]
at com.ning.http.client.providers.netty.request.body.BodyFileRegion.transferTo(BodyFileRegion.java:47) ~[async-http-client-1.9.19.jar:na]
at org.jboss.netty.channel.socket.nio.SocketSendBufferPool$FileSendBuffer.transferTo(SocketSendBufferPool.java:331) ~[netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.write0(AbstractNioWorker.java:201) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromUserCode(AbstractNioWorker.java:146) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:84) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:779) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:60) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:97) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:784) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:280) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleDownstream(ChunkedWriteHandler.java:121) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:582) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.Channels.write(Channels.java:704) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.Channels.write(Channels.java:671) [netty-3.10.1.Final.jar:na]
at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:348) [netty-3.10.1.Final.jar:na]
at com.ning.http.client.providers.netty.request.body.NettyBodyBody.write(NettyBodyBody.java:79) [async-http-client-1.9.19.jar:na]
at com.ning.http.client.providers.netty.request.NettyRequestSender.writeRequest(NettyRequestSender.java:338) [async-http-client-1.9.19.jar:na]
at com.ning.http.client.providers.netty.handler.HttpProtocol.exitAfterHandling100(HttpProtocol.java:279) [async-http-client-1.9.19.jar:na]
at com.ning.http.client.providers.netty.handler.HttpProtocol.handleHttpResponse(HttpProtocol.java:433) [async-http-client-1.9.19.jar:na]
Source: (StackOverflow)