emailjs/emailjs-tcp-socket

Tcp Socket seems to fails when sending (smtpclient) data larger then 16384 bytes

Stefano1964 opened this issue · 15 comments

Hi, for first a big thanks to having developed such amazing class system to manage an email client.
I've built a complete email client with your emal.js class (no encryption).
Its' sencha touch + (browserbox, smtpclient, etc) + cordova app for iOS and Android.
It's working well, except that on the Android version it's failing (smtpclient.js client.send(data)) sending more then 16384 bytes, maybe related with this (not fixed): MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp@990b0ca
I got i timed out error from smtpclient
Any idea?

can you provide some more info on the environment? i am fairly sure that the bug is not from the socket itself but rather from the smtpclient.
what smtp server are yout talking to? is this reproducible?

I'm testing with gmail account, with ssl, it's only an Android issue, it's working on iOS. I've tested with android 4.4.4, 5.1.1 and 6.01. with the last Cordova Android with Crosswalk plugin and the last Chrome cordova Plugin. Of course i'm using the last email.js library. If you need more info let me know.

damn ... an idea: could you debug what the socket actually does, and/or log the network activity? my guess is that the error is in here somewhere: https://github.com/whiteout-io/smtpclient/blob/master/src/smtpclient.js#L568-L589

I've just played with this trying to increase the timeout (TIMEOUT_SOCKET_MULTIPLIER from 01. to 1 or more) but with no luck, i've not played with TIMEOUT_SOCKET_LOWER_BOUND. I try to log network activity

For first, i've tried with another email provider, same result. It's working on iOS (zero problem), but it's not working on Android. So it's not a gmail issue. I've tried putting extra console message in smtpclient,
the timeout is always > 10000 (10sec) for succesful message sent (<16kb) and for unsucessful messages (>16kb), smtpclient in this case is hanging on send payload, it's not receiving response form server. I've some doubt is an smtpclient issue, the code (javascript) is same for iOS and Android, the difference is in the chrome socket plugin. What do you think?

I've tried your app whiteout mail on Android, same problem with messages > 16kb (text only, no attachment), not sending. Same gmail account that i've used for the other test.

Hi Felix, i'm pretty shure that's the problem is with ChromeSocketsTcp.java.
What happen is when i send a mailbody the smtpclient send 2 chunk, the first with the data and the second is a 3 bytes len (the terminator?). When the mailbody is larger than 16kb this callback:
if (recvBytes != null) {
JSONObject info = new JSONObject();
info.put("socketId", socketId);
sendReceiveEvent(new PluginResult(Status.OK, info));
sendReceiveEvent(new PluginResult(Status.OK, recvBytes));
Log.i("DEBUG", "DATA RETURN: " + recvBytes.length);
}
in ChromeSocketsTcp.java is never called (the log.i is mine), so smtpclient return the timeout

I forgot to mention that all the data sended from smtpclient are received by ChromeSocketsTcp.java and sended, i can suppose there is a timing problem in ChromeSocketsTcp.java.
Also there this one in setPipeToFileProperties function
uriOutputStream = webView.getResourceApi().openOutputStream(outputUri, append);
the webview in this case is the crosswalk webview...

nice observation! can you reference this issue in the cca project?

No way, tried without crosswalk plugin, same result. So it's not crosswalk..

I've opened an issue but no response till now:
MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp#9

that's some seriously impressive debugging right there :)

Hi Felix, i've fixed it. Now it's working, i can send mailbody of some MB. I'll test a little more.
The bug is exactly the one i've posted on cca.

ok, seems like this issue can be closed