Comments (24)
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.
Will investigate this.
from androidasync.
Could you let me know your android version?
from androidasync.
samsung galaxy s3 Android OS 4.0
from androidasync.
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.
What version of AndroidAsync?
from androidasync.
The issue seems to be with keepalive/socket recycling. Will take a look.
from androidasync.
I did this over 10000 runs, no issues. Let me know your AndroidAsync version.
from androidasync.
androidasync 1.1.2
from androidasync.
very unfortunately i reproduce it with androidasync 1.1.5
from androidasync.
I will give a more detailed description later, if you still can not find it
from androidasync.
Can you give me a url to test against?
from androidasync.
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.
If you can turn on verbose debugging, and send me the log including the server headers, that would help.
from androidasync.
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.
Can i shutdown the keep-alive feature in client side?
from androidasync.
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.
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.
Using Ion.configure().setAsyncHttpRequestFactory, you can create a AsyncHttpRequest, and remove the keep-alive header.
from androidasync.
Yes, it's Erlang. But can i take advantage of websocket if i change to ion ?
from androidasync.
Oh sorry, was confused, thought this was ion..
Yes, you can remove the keep-alive header from the AsyncHttpRequest.
from androidasync.
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.
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.
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)
- websocket server will close when receive data in version 3.0.8
- websocket server will block after send big text string HOT 1
- java.net.ConnectException: failed to connect to
- version:3.1.0,AsyncHttpServer not work
- Using AyncDataGram Server to Broadcast data to all clients connected to It
- AsyncNetworkSocket allocator give currentAlloc 0 most of time because of it unable to read and write using AsyncSocket
- 设置返回值code无效,啥情况 HOT 1
- mDataHandler failed to consume data HOT 1
- Callback is not received when network is poor and connection is terminated from other End HOT 1
- Version in the readme is old
- exception when connect to server HOT 1
- Running websocket server in background
- Can not add Http Header HOT 2
- Following the basic websocket example code, but HOT 1
- client got Connection reset by peer error when try to send binary message HOT 2
- Does the library use some Tracking link? HOT 2
- Finf
- How to do server support Multi-Threading and High concurrency HOT 2
- NullPointerException in HybiParser ( version 3.1.0 )
- mp3 with mediaplayer of android can not play over http
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 androidasync.