Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24226] Windows: Phone TCP Write Error

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-01-23T02:04:35.000+0000
Affected Version/sRelease 6.1.0
Fix Version/sRelease 6.1.0
ComponentsWindows phone
Labelserror, tcp, undefined, windows, windowsphone
ReporterSandro Lain
AssigneeKota Iguchi
Created2016-11-16T06:14:16.000+0000
Updated2017-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

FileDateSize
TCPWriteErrorScreenShot.PNG2017-02-23T00:19:43.000+000035571

Comments

  1. Sandro Lain 2016-12-06

    Hello, there are updates on this issue?
  2. Mostafizur Rahman 2016-12-19

  3. Gary Mathews 2017-01-21

    master: https://github.com/appcelerator/titanium_mobile_windows/pull/931
  4. Sandro Lain 2017-01-25

    Hello, I made a comment on github. The application crashes problem seems solved but not yet seem to be proper communication.
  5. Abir Mukherjee 2017-02-23

    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!
  6. Kota Iguchi 2017-02-23

    [~amukherjee] Yes, looking good! (y)

JSON Source