Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24336] Windows: App crashes when Ti.Network.Socket.TCP fails to connect

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-01-25T04:06:07.000+0000
Affected Version/sRelease 6.1.0
Fix Version/sRelease 6.1.0
ComponentsWindows
Labelsn/a
ReporterKota Iguchi
AssigneeGary Mathews
Created2017-01-23T04:42:11.000+0000
Updated2017-01-25T19:16:43.000+0000

Description

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();

Comments

  1. Gary Mathews 2017-01-24

    master: https://github.com/appcelerator/titanium_mobile_windows/pull/933
  2. Samir Mohammed 2017-01-25

    Verified fix, Error callback 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*
       Lumia 640 LTE (RM-1073) (OS Build 10.0.14393.693)
       Operating System
       Name                        = Microsoft Windows 10 Pro
       Version                     = 10.0.14393
       Architecture                = 64bit
       

    CPUs = 4

    Memory = 17034395648 Node.js Node.js Version = 4.6.0 npm Version = 2.11.3 Titanium SDK SDK Version = 6.1.0.v20170125103400

JSON Source