Ti.Nework.Socket.TCP doesn't invoke
error callback on
connect() when it fails to connect to the server. App crashes instead.
Steps to reproduce: Run following code when server isn't up.
var win = Ti.UI.createWindow();
var lbl = Ti.UI.createLabel({
text: 'TCP Test'
});
win.add(lbl);
win.addEventListener('open', function () {
var socket = Ti.Network.Socket.createTCP({
host: '192.168.x.xx',
port: 6262,
timeout: 3000,
connected: function (e) {
console.log("[TEST] connected");
},
error: function (e) {
socket = null;
alert("[TEST] socket error");
console.error(e);
}
});
console.log("[TEST] open connection");
socket.connect();
});
win.open();
master: https://github.com/appcelerator/titanium_mobile_windows/pull/933
Verified fix,
Errorcallback is now invoked when the app fails to connect to the server and the App no longer crashes. This was tested with the test coded provided by [~gmathews] in https://github.com/appcelerator/titanium_mobile_windows/pull/933. *Environment*