[TIMOB-25696] Windows: Network.TCP causes app crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-22T14:01:38.000+0000 |
Affected Version/s | Release 7.0.0 |
Fix Version/s | Release 7.1.0 |
Components | Windows |
Labels | n/a |
Reporter | Kota Iguchi |
Assignee | Kota Iguchi |
Created | 2018-01-23T06:09:40.000+0000 |
Updated | 2018-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);
});
https://github.com/appcelerator/titanium_mobile_windows/pull/1173
Master PR merged, [~kiguchi] Could you make a backport when you have time, thanks!
7_1_X backport: https://github.com/appcelerator/titanium_mobile_windows/pull/1198
7_1_X PR merged, resolving and will close when changes verified in released SDK
Verified changes in 7.2.0.v20180302144729 and 7.1.0.v20180302141418. Closing ticket