Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25696] Windows: Network.TCP causes app crash

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-02-22T14:01:38.000+0000
Affected Version/sRelease 7.0.0
Fix Version/sRelease 7.1.0
ComponentsWindows
Labelsn/a
ReporterKota Iguchi
AssigneeKota Iguchi
Created2018-01-23T06:09:40.000+0000
Updated2018-05-16T23:37:55.000+0000

Description

Application crashes when there's runtime error during TCP callback. For example, following app crashes without any error logs.
var win = Ti.UI.createWindow({ backgroundColor: 'white' });

win.addEventListener('open', function () {
    console.log('Connecting to server');
    var socket = Ti.Network.Socket.createTCP({
        host: '127.0.0.1', port: 6262,
        connected: function (e) {
            Ti.API.info('Connected to server at port ' + port);
            win.backgroundColor = 'green';
        },
        error: function (e) {
            alert(e.error);
            Ti.API.info('Error connecting to server (' + e.errorCode + '): ' + e.error);
            win.backgroundColor = 'red';
        },
    });
    socket.connect();
});

win.open();
Expected: This Titanium app should not crash. This should alert Can't find variable: port because there's runtime error in connected callback (the variable port is not defined). Here's a sample server code to debug the issue. Launch this using node server.js in Node.js in order to test this.
var net = require('net'),
	port = 6262;

net.createServer(function (socket) {
	console.log('client ' + socket.remoteAddress + ' connected');

	socket.on('end', function () {
		console.log('client ' + socket.remoteAddress + ' disconnected');
	});

}).listen(port, function() {
	console.log('server listening on port ' + port);
});

Comments

  1. Kota Iguchi 2018-01-23

    https://github.com/appcelerator/titanium_mobile_windows/pull/1173
  2. Ewan Harris 2018-02-21

    Master PR merged, [~kiguchi] Could you make a backport when you have time, thanks!
  3. Kota Iguchi 2018-02-22

    7_1_X backport: https://github.com/appcelerator/titanium_mobile_windows/pull/1198
  4. Ewan Harris 2018-02-22

    7_1_X PR merged, resolving and will close when changes verified in released SDK
  5. Ewan Harris 2018-03-05

    Verified changes in 7.2.0.v20180302144729 and 7.1.0.v20180302141418. Closing ticket

JSON Source