Giter Club home page Giter Club logo

Comments (24)

xumingthepoet avatar xumingthepoet commented on August 28, 2024

Finally, i make it run . Though it doesn't make me comfortable.

String my_way() {
AsyncHttpPost httpPost = new AsyncHttpPost("URL");
httpPost.setBody(new StringBody("StringBody"));
// Future f = AsyncHttpClient.getDefaultInstance().executeString(httpPost);
Future f = new AsyncHttpClient(AsyncServer.getDefault()).executeString(httpPost); // here is what i change
String s = f.get();
return s;
}

And it is OK. I don't think it is a good way,but it solved the problem.

from androidasync.

koush avatar koush commented on August 28, 2024

Will investigate this.

from androidasync.

koush avatar koush commented on August 28, 2024

Could you let me know your android version?

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

samsung galaxy s3 Android OS 4.0

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

And i did not use it in UI thread, instead :

private static ExecutorService executorService = Executors.newSingleThreadExecutor();

exectorService.submit(new Runnable() {
public void run() {
my_way();
}
});

don't know if it matters

from androidasync.

koush avatar koush commented on August 28, 2024

What version of AndroidAsync?

from androidasync.

koush avatar koush commented on August 28, 2024

The issue seems to be with keepalive/socket recycling. Will take a look.

from androidasync.

koush avatar koush commented on August 28, 2024

I did this over 10000 runs, no issues. Let me know your AndroidAsync version.

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

androidasync 1.1.2

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

very unfortunately i reproduce it with androidasync 1.1.5

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

I will give a more detailed description later, if you still can not find it

from androidasync.

koush avatar koush commented on August 28, 2024

Can you give me a url to test against?

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

I test it against other urls and the problem is gone.

maybe it is an another keep-alive issue in my server side.

i am trying to make it on aws and give a url

from androidasync.

koush avatar koush commented on August 28, 2024

If you can turn on verbose debugging, and send me the log including the server headers, that would help.

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

D/androidasync( 8696): (150 ms) http://192.168.2.80:8080: Recycling keep-alive socket
D/androidasync( 8696): (0 ms) http://192.168.2.80:8080: Executing request.
D/androidasync( 8696): (3 ms) http://192.168.2.80:8080: Reusing keep-alive socket
V/androidasync( 8696): (21 ms) http://192.168.2.80:8080: Received headers: HTTP/1.1 505 HTTP Version Not Supported
V/androidasync( 8696): connection: close
V/androidasync( 8696): server: Cowboy
V/androidasync( 8696): date: Tue, 23 Jul 2013 06:11:20 GMT
V/androidasync( 8696): content-length: 0
V/androidasync( 8696):
V/androidasync( 8696): (22 ms) http://192.168.2.80:8080: Final (post cache response) headers: HTTP/1.1 505 HTTP Version Not Supported
V/androidasync( 8696): connection: close
V/androidasync( 8696): server: Cowboy
V/androidasync( 8696): date: Tue, 23 Jul 2013 06:11:20 GMT
V/androidasync( 8696): content-length: 0
V/androidasync( 8696):
D/androidasync( 8696): (24 ms) http://192.168.2.80:8080: Connection successful
W/androidasync( 8696): http response : Empty
W/androidasync( 8696): ===================
D/androidasync( 8696): (0 ms) http://192.168.2.80:8080: Executing request.
D/androidasync( 8696): (2 ms) http://192.168.2.80:8080: Connecting socket
V/androidasync( 8696): (137 ms) http://192.168.2.80:8080: Received headers: HTTP/1.1 200 OK
V/androidasync( 8696): connection: keep-alive
V/androidasync( 8696): server: Cowboy
V/androidasync( 8696): date: Tue, 23 Jul 2013 06:11:20 GMT
V/androidasync( 8696): content-length: 122
V/androidasync( 8696):
V/androidasync( 8696): (139 ms) http://192.168.2.80:8080: Final (post cache response) headers: HTTP/1.1 200 OK
V/androidasync( 8696): connection: keep-alive
V/androidasync( 8696): server: Cowboy
V/androidasync( 8696): date: Tue, 23 Jul 2013 06:11:20 GMT
V/androidasync( 8696): content-length: 122
V/androidasync( 8696):
D/androidasync( 8696): (141 ms) http://192.168.2.80:8080: Connection successful
W/androidasync( 8696): http response : Right Message
W/androidasync( 8696): ===================
D/androidasync( 8696): (149 ms) http://192.168.2.80:8080: Recycling keep-alive socket
D/androidasync( 8696): (0 ms) http://192.168.2.80:8080: Executing request.
D/androidasync( 8696): (2 ms) http://192.168.2.80:8080: Reusing keep-alive socket
V/androidasync( 8696): (19 ms) http://192.168.2.80:8080: Received headers: HTTP/1.1 505 HTTP Version Not Supported
V/androidasync( 8696): connection: close
V/androidasync( 8696): server: Cowboy
V/androidasync( 8696): date: Tue, 23 Jul 2013 06:11:20 GMT
V/androidasync( 8696): content-length: 0
V/androidasync( 8696):
V/androidasync( 8696): (21 ms) http://192.168.2.80:8080: Final (post cache response) headers: HTTP/1.1 505 HTTP Version Not Supported
V/androidasync( 8696): connection: close
V/androidasync( 8696): server: Cowboy
V/androidasync( 8696): date: Tue, 23 Jul 2013 06:11:20 GMT
V/androidasync( 8696): content-length: 0
V/androidasync( 8696):
D/androidasync( 8696): (22 ms) http://192.168.2.80:8080: Connection successful
W/androidasync( 8696): http response : Empty
W/androidasync( 8696): ===================

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

Can i shutdown the keep-alive feature in client side?

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

And

AsyncHttpPost httpPost = new AsyncHttpPost("http://ec2-54-249-214-174.ap-northeast-1.compute.amazonaws.com:8080");
httpPost.setLogging("androidasync", Log.VERBOSE);
httpPost.setBody(new StringBody("{"c":{"u":"53cbe946ccfe73bb","l":10,"t":"n","s":3,"b":100},"v":1,"e":{},"a":"s"}"));
String s = AsyncHttpClient.getDefaultInstance().executeString(httpPost).get();
boolean b = true;
while( b) {
Log.w("androidasync", "http response : "+s);
s = AsyncHttpClient.getDefaultInstance().executeString(httpPost).get();
}

from androidasync.

koush avatar koush commented on August 28, 2024

This is bizarre:

HTTP/1.1 505 HTTP

A server that doesn't support HTTP/1.1? What sort of server is this? Cowboy is erlang?

from androidasync.

koush avatar koush commented on August 28, 2024

Using Ion.configure().setAsyncHttpRequestFactory, you can create a AsyncHttpRequest, and remove the keep-alive header.

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

Yes, it's Erlang. But can i take advantage of websocket if i change to ion ?

from androidasync.

koush avatar koush commented on August 28, 2024

Oh sorry, was confused, thought this was ion..

Yes, you can remove the keep-alive header from the AsyncHttpRequest.

from androidasync.

xumingthepoet avatar xumingthepoet commented on August 28, 2024

I think that Cowboy fails to recognize a reused socket, so it throws a 505 error.

I change keep-alive to close after every request is handled, then it runs well.

I will make a deep investigation to Cowboy , Thanks for the help~

from androidasync.

koush avatar koush commented on August 28, 2024

Cowboy seems to request a keep-alive

connection: keep-alive

And I know that keepalive works fine on everythign else... I wonder what is causing this.

from androidasync.

koush avatar koush commented on August 28, 2024

If you can determine that this is a problem with this library, and not Cowboy, please feel free to reopen.

from androidasync.

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.