[TIMOB-24226] Windows: Phone TCP Write Error
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-01-23T02:04:35.000+0000 |
Affected Version/s | Release 6.1.0 |
Fix Version/s | Release 6.1.0 |
Components | Windows phone |
Labels | error, tcp, undefined, windows, windowsphone |
Reporter | Sandro Lain |
Assignee | Kota Iguchi |
Created | 2016-11-16T06:14:16.000+0000 |
Updated | 2017-02-23T01:18:46.000+0000 |
Description
Hello
I need to develop a Windows Phone app that performs communication via TCP socket. Specifically, it is an extension of an already developed apps for iOS and Android platforms with Titanium SDK.
Seeing that the development of the TCP part is found only in the 6.1.0.x SDK version I have updated Appcelerator SDK and Studio to the latest versions.
The TCP client implementation is present and working but I encountered some problems with sending messages, specifically it seems that the second message sent creates an error that crashes the application.
I quote here the the error log and test the application code.
The TCP server is a simple nodejs echo script that responds with the message received.
*Studio Console Log*
{noformat}
-- Start application log -----------------------------------------------------
[INFO] [TEST] open connection
[INFO] [TEST] connected
[INFO] : Finished launching the application
[INFO] [TEST] try to send
[INFO] [TEST] sent
[INFO] [TEST] received: 0 0 0 0 14 a0
[INFO] [TEST] try to send
[ERROR] : ----- Titanium Javascript Runtime Error -----
[ERROR] : In undefined: undefined,undefined
[ERROR] : Message: Uncaught Error: undefined
[INFO] : Disconnected from app
-- End application log -------------------------------------------------------
{noformat}
*Test Code*
var win = Ti.UI.createWindow();
var lbl = Ti.UI.createLabel({
text: 'TCP Test'
});
win.add(lbl);
win.addEventListener('open', function()
{
var itv;
var socket = Ti.Network.Socket.createTCP({
host: '192.168.1.88',
port: 6262,
timeout: 3000,
connected: function(e)
{
console.log("[TEST] connected");
Ti.Stream.pump(e.socket, function(e)
{
if (e.bytesProcessed == -1)
{
// Socket :: END of received message
return;
}
var res = [];
for(var i = 0, len = e.buffer.length; i < len; i++)
{
res.push(e.buffer[i].toString(16));
}
console.log("[TEST] received: " + res.join(" "));
}, 1024, true);
itv = setInterval(function()
{
if(!socket)
{
clearInterval(itv);
return;
}
var buff = Ti.createBuffer({
length: 6
});
buff[0] = 0x00;
buff[1] = 0x00;
buff[2] = 0x00;
buff[3] = 0x00;
buff[4] = 0x14;
buff[5] = 0xA0;
console.log("[TEST] try to send");
Ti.Stream.write(socket, buff, function()
{
console.log('[TEST] sent');
});
}, 1000);
},
error: function(e)
{
clearInterval(itv);
socket = null;
console.error("[TEST] socket error");
console.error(e);
}
});
console.log("[TEST] open connection");
socket.connect();
});
win.open();
Attachments
File | Date | Size |
---|---|---|
TCPWriteErrorScreenShot.PNG | 2017-02-23T00:19:43.000+0000 | 35571 |
Hello, there are updates on this issue?
master: https://github.com/appcelerator/titanium_mobile_windows/pull/931
Hello, I made a comment on github. The application crashes problem seems solved but not yet seem to be proper communication.
Tested using environment: NPM Version: 2.15.9 Node Version: 4.5.0 Windows OS: Windows 10 Build 14393.693 Appc CLI: 6.1.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.1.0.v20170220091247 Appcelerator Studio, build: 4.8.1.201612050850 Windows OS: Windows 10 Build 14393.693 Windows Device: 10.0.14393.693 Validated that messages are being sent between demo client app and server demo app. [~kota] Can you please verify from the screenshot, that these are the expected messages from the console and the node app? !TCPWriteErrorScreenShot.PNG|thumbnail!
[~amukherjee] Yes, looking good! (y)