On 10/23/2014 05:17 AM, Jovan Gerodetti wrote:
The messaging app Loqui[1] uses a TCP Socket to upload files to the
WhatsApp server[2]. But on 2.1 and 2.2 we are experiencing that the
Socket gets closed in the middle of the upload[3]. The console shows
this error:
/
NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS: [JavaScript Error: "Socket
not open." {file:
"jar:file:///system/b2g/omni.ja!/components/TCPSocket.js" line:
663}]'[JavaScript Error: "Socket not open." {file:
"jar:file:///system/b2g/omni.ja!/components/TCPSocket.js" line: 663}]'
when calling method: [nsIDOMTCPSocket::send]/
I would suggest opening a bug in the "Core" product under the "DOM:
Device Interfaces" component and providing a log from your app to help
analyze what the problem might be. (I see you have very nice logging
code!) You can use this link to get started:
https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=DOM%3A%20Device%20Interfaces
I took a look at the use of MozTCPSocket to see if any issues jumped out
at me. The code looks correct, but there are a few enhancements worth
considering:
- TCPSocket's buffer threshold for waiting for a drain is at 64k, so
the code's current use of 1k is suboptimal.
- The code reads the entirety of the Blob into memory and keeps it
around for the duration of the file send. For large files, this could
lead to excess memory usage. I realize an MD5 hash is computed, but it
might make sense to simply stream the contents of the file twice; once
for the MD5, and once for the actual sending. The Firefox OS email app
has some example code related to chunked Blob sending at
https://github.com/mozilla-b2g/gaia-email-libs-and-more/blob/master/js/worker-support/net-main.js
Andrew
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g