Comments (51)
I tried:
Ion.getDefault(context).getHttpClient().getSSLSocketMiddleware().setSSLContext(SSLContext.getInstance("SSLv3"));
but doesn't work... it start at 0% and keeps there. any hint?
from androidasync.
the most strange thing is that it happens when it gets to 100%, not before. so I'm not sure if using sslv3 is really the solution. I mean it should happen at any "%"... I assume. TIA
from androidasync.
I'm not sure if this is right or not, but on file AsyncSSLSocketWrapper.java line 147
sslContext = SSLContext.getInstance("Default");
it doesn't call sslContext.init(...) after that, is that right? (if an exception occurs it is called, but if is not, is not called)
from androidasync.
I think the problem is that it continues to expect data after it finish.
I changed some code:
on file AsyncSSLSocketWrapper.java line 86: added some Log.d(...)
while (true) {
if (b.remaining() == 0 && bb.size() > 0) {
b = bb.remove();
}
int remaining = b.remaining();
Log.i("SL", "SSSSS REM1:"+remaining+" bb:"+bb.size());
SSLEngineResult res = engine.unwrap(b, mReadTmp);
if (res.getStatus() == Status.BUFFER_OVERFLOW) {
Log.i("SL", "SSSSS OVERFLOW");
addToPending(transformed);
mReadTmp = ByteBufferList.obtain(mReadTmp.remaining() * 2);
remaining = -1;
}
else if (res.getStatus() == Status.BUFFER_UNDERFLOW) {
Log.i("SL", "SSSSS UNDERFLOW");
bb.addFirst(b);
if (bb.size() <= 1) {
break;
}
remaining = -1;
b = bb.getAll();
}
handleResult(res);
if (b.remaining() == remaining) {
Log.i("SL", "SSSSS ====");
bb.addFirst(b);
break;
}
Log.i("SL", "SSSSS REM2:"+remaining+" bb:"+bb.size());
}
and get this results:
I/SL: SSSSS REM1:5432 bb:0
I/SL: SSSSS REM2:5432 bb:0
I/SL: SSSSS REM1:5353 bb:0
I/SL: SSSSS REM2:5353 bb:0
I/SL: SSSSS REM1:9 bb:0
I/SL: SSSSS REM2:9 bb:0
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS ====
I/SL: SSSSS REM1:47 bb:0
I/SL: SSSSS REM2:47 bb:0
I/SL: SSSSS REM1:41 bb:0
I/SL: SSSSS REM2:41 bb:0
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS UNDERFLOW
I/SL: SSSSS REM1:27 bb:0
the error happens always when reaching the 100%.
W/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac
W/System.err: at org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:485)
W/System.err: at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
W/System.err: at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:93)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
W/System.err: at com.koushikdutta.async.Util.emitAllData(Util.java:20)
W/System.err: at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
W/System.err: at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
W/System.err: at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
W/System.err: at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
W/System.err: at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)
any idea? thanks
from androidasync.
If there's any way you can expose a server and url to me, I can investigate further. I have no idea what the problem is otherwise.
from androidasync.
no, because it is a server inside the company. what can I test? tnx
from androidasync.
should be something after the SSSS =====?
from androidasync.
please try the changes in the issue55 branch. May fix it.
from androidasync.
actually hold on.
from androidasync.
Ok, now try issue55 branch. Had to add one more change.
from androidasync.
oh.. ok will download again.
from androidasync.
:(
it gives me this error:
W/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac
W/System.err: at org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:485)
W/System.err: at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
W/System.err: at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:91)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
W/System.err: at com.koushikdutta.async.Util.emitAllData(Util.java:20)
W/System.err: at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
W/System.err: at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
W/System.err: at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
W/System.err: at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
W/System.err: at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)
from androidasync.
also the oncomplete returns this exception:
java.lang.Exception: connection closed before response completed.
at com.koushikdutta.async.http.AsyncHttpResponseImpl$3.onCompleted(AsyncHttpResponseImpl.java:85)
at com.koushikdutta.async.AsyncSSLSocketWrapper.report(AsyncSSLSocketWrapper.java:364)
at com.koushikdutta.async.AsyncSSLSocketWrapper.access$100(AsyncSSLSocketWrapper.java:27)
at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:120)
at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
at com.koushikdutta.async.Util.emitAllData(Util.java:20)
at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)
from androidasync.
I;m adding Log.d everywhere:
while (true) {
if (b.remaining() == 0 && bb.size() > 0) {
b = bb.remove();
}
int remaining = b.remaining();
Log.i("SL", "SSSSS REM1:" + remaining + " bb:" + bb.size());
if (read == null)
read = ByteBufferList.obtain(remaining * 2);
SSLEngineResult res = engine.unwrap(b, read);
addToPending(transformed, read);
if (res.getStatus() == Status.BUFFER_OVERFLOW) {
Log.i("SL", "SSSSS OVER");
remaining = -1;
read = ByteBufferList.obtain(read.capacity() * 2);
}
else if (res.getStatus() == Status.BUFFER_UNDERFLOW) {
Log.i("SL", "SSSSS UNDER");
read = null;
bb.addFirst(b);
Log.i("SL", "SSSSS UNDER bb.size:"+bb.size());
if (bb.size() <= 1) {
break;
}
remaining = -1;
b = bb.getAll();
}
else {
Log.i("SL", "SSSSS read=null");
read = null;
}
handleResult(res);
Log.i("SL", "SSSSS REM2: b"+b.remaining()+" rem:"+remaining);
if (b.remaining() == remaining) {
Log.i("SL", "SSSSS =====");
bb.addFirst(b);
break;
}
}
Log.i("SL", "SSSSS emit");
Util.emitAllData(AsyncSSLSocketWrapper.this, transformed);
from androidasync.
I/SL: SSSSS REM1:5432 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b5353 rem:5432
I/SL: SSSSS REM1:5353 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b9 rem:5353
I/SL: SSSSS REM1:9 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:9
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:0
I/SL: SSSSS =====
I/SL: SSSSS emit
I/SL: SSSSS REM1:47 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b41 rem:47
I/SL: SSSSS REM1:41 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:41
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS UNDER
I/SL: SSSSS UNDER bb.size:0
I/SL: SSSSS emit
I/SL: SSSSS REM1:134 bb:0
from androidasync.
again, at 100%
and the ==== happen at 0%
from androidasync.
notice that bb.size is always 0. so when goes in buffer_under.. it is going inside the "break;".. is that right?
from androidasync.
Yes, breaking is correct. It needs to emit more data to continue; hence the buffer underlow. It is weird that it consumes all the data on undeflow. Hmm.
from androidasync.
try this:
change:
if (b.remaining() == 0 && bb.size() > 0) {
b = bb.remove();
}
to:
if (b.remaining() == 0 && bb.size() > 0) {
b = bb.getAll();
}
from androidasync.
no....
/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac
/System.err: at org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:485)
/System.err: at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
/System.err: at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:93)
/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
/System.err: at com.koushikdutta.async.Util.emitAllData(Util.java:20)
/System.err: at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
/System.err: at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
/System.err: at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
/System.err: at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
/System.err: at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)
from androidasync.
Try using SSLEngine.setEnabledProtocols to hardcode enabling SSLv3.
from androidasync.
if (host != null) {
engine = sslContext.createSSLEngine(host, port);
}
else {
engine = sslContext.createSSLEngine();
}
after those lines add,
engine.setEnabledProtocols(new String[] { "SSLv3" });
from androidasync.
ok, will try. with the bb.getAll or bb.remove ?
from androidasync.
Try both, but I think forcing only SSLv3 may fix this.
from androidasync.
with getall and with .remove gives the same error. should I try the master branch with the sslv3 line?
from androidasync.
Remember that I'm using Ion, is Ion using that SSLContext?
from androidasync.
all comments I found on google said that using sslv3 should solve that
from androidasync.
Try the SSLv3 fix. It doesn't matter which branch. You'll need to make the change in AndroidAsync. See the code I mentioned above.
from androidasync.
it doesn't work: I changed:
if (host != null) {
engine = sslContext.createSSLEngine(host, port);
}
else {
engine = sslContext.createSSLEngine();
}
engine.setEnabledProtocols(new String[] { "SSLv3" });
W/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac
I/SL: SSSSS REM1:5432 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b5353 rem:5432
I/SL: SSSSS REM1:5353 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b9 rem:5353
I/SL: SSSSS REM1:9 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:9
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:0
I/SL: SSSSS =====
I/SL: SSSSS REM1:71 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b65 rem:71
I/SL: SSSSS REM1:65 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:65
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS UNDER
I/SL: SSSSS UNDER bb.size:0
I/SL: SSSSS REM1:134 bb:0
from androidasync.
Try SSLv2 then.
from androidasync.
it hangs at 0%
from androidasync.
Try TLSv1.2.
Also try disabling SSLv3 on your server. It's apparently insecure anyways.
from androidasync.
the server only works with tlsv1 and ssl3. do I have a way to contact you directly? I can give you tomorrow if you can access, to a server so you can test it. but it needs to be during tomorrow, I don't know if you can..?
from androidasync.
I will make some tests anyway. I found that in some cases it works, when using the call from another part of the app. but not always. I will let you know. thanks
from androidasync.
Try TLSv1 then. Trying to determine what the issue is.
koushikdutta _ at _ hotmail.com is my address
from androidasync.
I just sent you an email. Thanks!
btw, it didn't work with TLSv1 :(
from androidasync.
do you think you will can test it today? thanks
from androidasync.
Not today, probably tomorrow or monday.
from androidasync.
ok, I need to disable the account. I will enable it again tomorrow and send you an email, if you are ok with that... thanks!
from androidasync.
ok
from androidasync.
Resolved as probable issue with SSLv3 stack on Apache server.
from androidasync.
From email:
I tested this request a dozen times against my own http(s) server. It worked every time.
I tested this many times against your NON-https, normal http post path, and it worked every time.
I tested this against your https server, and it fails fairly consistently.
From my searching, Apache is known to have issues with SSL termination using SSLv3. I'm fairly confident that the issue is with the server and client interaction over https. The client (AndroidAsync) is not at fault (since it works with the three other servers I tested, including your own http, not https, server). But it is triggering the failure code path fairly consistently for whatever reason on https.
I would recommend changing the configuration of the apache server, as I can not fix this in the library... there's nothing I can fix that I can tell.
from androidasync.
Hi @UXDart , can you try this out:
from androidasync.
@hiddenmin If possible, please give me a web server I can test against.
from androidasync.
https://node.whereteam.com:8080/upload.php
I tested last commit with Ion no SSLException but freeze after upload about 25kbytes.
from androidasync.
@hiddenmin Thanks, I just fixed the hang issue with:
04f2040
I then tested a 1MB post of a file and a couple fields against:
https://node.whereteam.com:8080/upload.php
This resulted in an "ok" response.
Let me know if this resolves your issue. If not, please provide a Phone model and Android version, and I can debug further.
from androidasync.
Thanks @koush. You saved my life.
from androidasync.
@UXDart Do you mind seeing if this resolved your bad_record_mac as well? I think they were the same bug.
from androidasync.
thanks, I will check it and let you know
from androidasync.
sorry I couldn't test it before. it works!!!! :) this is great! thanks!
from androidasync.
Great!
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.