[AC-2620] Data transmission via socket seems corruptted on latest SDK
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-02-04T05:36:02.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | api, ios |
Reporter | David He |
Assignee | Ritu Agrawal |
Created | 2014-01-22T03:46:00.000+0000 |
Updated | 2016-03-08T07:41:42.000+0000 |
Description
Steps to reproduce
1. Have a network printer configured with IP 192.168.20.175 and Port 9100
Make sure the computer where emulator running on and printer are both in the same network
2. Drop the attachment into project Documents folder
3. Run the code below using iOS 7.0.3 and Ti SDK 3.2.0
Test Code
var win = Ti.UI.createWindow({
title : "Test Window"
});
var t = Ti.UI.createButton({
title : "generate",
bottom : 10,
height : 40
});
win.add(t);
t.addEventListener("click", function(e) {
var xData = psc();
letsPrint(xData);
});
function psc() {
try {
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "signature_bin.bin");
// var sigBin = sigBlob;
// //f.write("Signature: \n");
// var bo = f.write(sigBin);
var fileStream = f.open(Ti.Filesystem.MODE_READ);
var buf = Ti.Stream.readAll(fileStream);
return buf;
} catch (e) {
alert(e);
}
}
function letsPrint(data) {
var socket = Ti.Network.Socket.createTCP({
host : '192.168.20.175',
port : 9100,
connected : function(e) {
Ti.API.info('Socket opened!');
Ti.Stream.pump(e.socket, readCallback, 1024, true);
Ti.Stream.write(socket, data, writeCallback);
},
error : function(e) {
Ti.API.info('Error (' + e.errorCode + '): ' + e.error);
},
});
socket.connect();
function writeCallback(e) {
Ti.API.info('Successfully wrote to socket.');
}
function readCallback(e) {
if (e.bytesProcessed == -1) {
}
try {
if (e.buffer) {
var received = e.buffer.toString();
Ti.API.info('Received: ' + received);
} else {
Ti.API.error('Error: read callback called with no buffer!');
}
} catch (ex) {
Ti.API.error(ex);
}
}
}
Expected Result
Signature printed out on docketActual Result
Nothing printed{color:red}But the above code produces expected result on iOS 6.0 and Ti.SDK 2.1.4{color}
Attachments
File | Date | Size |
---|---|---|
signature_bin.bin | 2014-01-22T03:46:00.000+0000 | 11994 |
Can anybody treat it urgently as our mobile product relies much on this and it cannot behave without the bug fix. Thanks
[~jialhe85@gmail.com] It is tedious to diagnose this issue with network printer setup. Can you please try to reproduce this issue with a simple node based server instead of printer? It would also help us to narrow down the problem and expedite the problem diagnosis.
Hi Ritu After hours of investigations, I found that it seems like a problem with Model window in 3.2.0. I will re-produce the test code later. Thanks
[~jialhe85@gmail.com] Did you get a chance to reproduce this problem with the model window?
Hi Ritu I am sorry that I could not reproduce this issue in model window. No idea why. Can you please close this ticket as invalid? Thanks
Closing this ticket as invalid based on reporter's request.