{ "id": "122736", "key": "AC-2236", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2013-12-29T19:35:55.000+0000", "created": "2013-11-21T02:32:50.000+0000", "labels": [ "android" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:41:14.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14551", "name": "Studio", "description": "Please enter tickets related to Titanium Studio here." }, { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Hi everybody and thanks for reading,\r\n\r\nI'm going through an issu and I really don't know how to handle it.\r\n\r\nFirst, I create a button to open a new window, instantiate a new socket and connect it to my computer through wifi. Here is the code :\r\n{code:title=button.js|borderStyle=solid}\r\n\r\nvar OptionWindow = require('display/OptionWindow');\r\nvar TactSocket = require('trans/tactSocket');\r\n\r\nstartButton.addEventListener('singletap',function(){\r\n new appDisplay().open({\r\n activityEnterAnimation: Ti.Android.R.anim.fade_in\r\n });\r\n new TactSocket(\"192.168.1.27\",2009).connect();\r\n});\r\n{code} \r\n\r\nWhen I close the window open before, I also want to close the socket, so here is the code in the window :\r\n{code:title=OptionWindow.js|borderStyle=solid} \r\n//create a window\r\nvar self = Ti.UI.createWindow({\r\n\tbackgroundColor:'#000000',\r\n\tnavBarHidden:true,\r\n\tfullscreen:true,\r\n\twindowSoftInputMode : Ti.UI.Android.SOFT_INPUT_ADJUST_RESIZE\r\n});\r\n\r\n//Listen to the 'close' event, and fire a new event 'app_close'\r\nself.addEventListener('close',function(){\r\n Ti.App.fireEvent('app_close');\r\n});\r\n{code}\r\n\r\nThen in my tactsocket function I did this :\r\n{code:title=tactSocket.js|borderStyle=solid}\r\nfunction tactSocket(host,port){\r\n var tactsocket = Ti.Network.Socket.createTCP({\r\n host : host,\r\n port : port,\r\n connected : function(e) {\r\n alert('connected socket);\r\n //alert(tactsocket.isWriteable); \r\n },\r\n error : function(e) {\r\n alert('Error (' + e.errorCode + '): ' + e.error);\r\n }\r\n });\r\n\r\n //Listen to the 'app_close' event to close the socket\r\n Ti.App.addEventListener('app_close',function(){ \r\n tactsocket.close();\r\n alert('socket closed'); \r\n });\r\n\r\n return self;\r\n}\r\n{code}\r\n\r\nWhat happen now : \r\n# Open the App\r\n# click start button\r\n# window open et socket connect, alert show me that the socket is well connected and i can write in the socket\r\n# close the window, alert show me that the socket is well closed\r\n# open the window again, alert show me that the socket is well connected, but this time I am unable to write in the socket, I get a runtime error saying the socket is not connected\r\n# close the window I also get a runtime error saying the socket is not connected\r\n\r\nMay be I'm missing something about socket.", "attachment": [], "flagged": false, "summary": "Android: Close a socket then reopen it, unable to write on it.", "creator": { "name": "marvin07ro", "key": "marvin07ro", "displayName": "Marvin Rosillette", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "marvin07ro", "key": "marvin07ro", "displayName": "Marvin Rosillette", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Windows 8, 64 bit\r\nTitanium Studio, build: 3.1.3.201309132423\r\nTitanium SDK v3.1.3.GA\r\nCLI version 3.1.2", "comment": { "comments": [ { "id": "281696", "author": { "name": "marvin07ro", "key": "marvin07ro", "displayName": "Marvin Rosillette", "active": true, "timeZone": "America/Los_Angeles" }, "body": "nothing ?", "updateAuthor": { "name": "marvin07ro", "key": "marvin07ro", "displayName": "Marvin Rosillette", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-11-27T19:39:08.000+0000", "updated": "2013-11-27T19:39:08.000+0000" }, { "id": "282285", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hi,\r\n\r\nThank your providing the code snippet. Since it is not the complete implementation of the scenario, we can't fully test it. We need runnable test case to provide you necessary feedback.\r\n\r\nBased on the code you posted, it looks like you are creating objects without assign those to any variable, so we will need to add variables to the test and see if this fails. For example,\r\n\r\nstartButton.addEventListener('singletap',function(){\r\n new appDisplay().open({\r\n activityEnterAnimation: Ti.Android.R.anim.fade_in\r\n });\r\n new TactSocket(\"192.168.1.27\",2009).connect();\r\n});\r\n\r\n\r\nThis segment of the code is just creating TackSocket without assigning it to anywhere. \r\n\r\nIf you can provide us more info, we can look into it further.\r\nRegards,\r\nMauro", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-12-04T00:00:51.000+0000", "updated": "2013-12-06T19:58:53.000+0000" }, { "id": "284163", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello Marvin,\nI created another testcase (i.e., create a new mobile project and paste this to the app.js): \n\n{code}\nvar win = Ti.UI.createWindow({\n\tbackgroundColor:'white',\n});\n\nvar createButton = Ti.UI.createButton({\n\ttitle:'create socket',\n\ttop:20,\n\tleft:20,\n});\n\nvar deleteButton = Ti.UI.createButton({\n\ttitle:'delete socket',\n\ttop:20, \n\tright:20,\n});\n\nvar tactsocket;\nvar host = \"74.125.20.105\";\nvar port = 80;\n \ncreateButton.addEventListener('click',function(){\n\ttactsocket = Ti.Network.Socket.createTCP({\n host : host,\n port : port,\n connected : function(e) {\n alert('connected socket');\n alert(e);\n },\n error : function(e) {\n alert('Error (' + e.errorCode + '): ' + e.error);\n }\n });\n\ttactsocket.connect();\n});\n\ndeleteButton.addEventListener('click',function(){\n\ttactsocket.close();\n\talert('deleted socket');\n});\n\nwin.add(createButton);\nwin.add(deleteButton);\nwin.open();\n{code}\n\nand looks like it's not failing (the socket will be reused after re initializing it with a .connect(). Can you please take a look and let us know if is working for you as well?\n\nFor more information on the sockets lifecycle, you can get into this doc:\n\nhttp://docs.appcelerator.com/titanium/3.0/#!/guide/TCP_Socket_API_Spec-section-29004739_TCPSocketAPISpec-Socketlifecycle\n\nBest,\nMauro", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-12-13T02:23:05.000+0000", "updated": "2013-12-13T02:23:05.000+0000" }, { "id": "286178", "author": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Hi Marvin Rosillette,\r\n\r\nWe are marking this ticket as \"cannot reproduce\". We posted a sample test case. Please let us know if you continue to get error with our test case. We wait for your feedback. If we don't hear back from you in a week, we will consider this issue resolved and close the ticket.", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-12-29T19:35:55.000+0000", "updated": "2013-12-29T19:35:55.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }