{"action":"closed","issue":{"url":"https://api.github.com/repos/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp/issues/12","repository_url":"https://api.github.com/repos/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp","labels_url":"https://api.github.com/repos/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp/issues/12/comments","events_url":"https://api.github.com/repos/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp/issues/12/events","html_url":"https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp/issues/12","id":132663807,"number":12,"title":"android.os.NetworkOnMainThreadException","user":{"login":"Hakog","id":12607532,"avatar_url":"https://avatars.githubusercontent.com/u/12607532?v=3","gravatar_id":"","url":"https://api.github.com/users/Hakog","html_url":"https://github.com/Hakog","followers_url":"https://api.github.com/users/Hakog/followers","following_url":"https://api.github.com/users/Hakog/following{/other_user}","gists_url":"https://api.github.com/users/Hakog/gists{/gist_id}","starred_url":"https://api.github.com/users/Hakog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hakog/subscriptions","organizations_url":"https://api.github.com/users/Hakog/orgs","repos_url":"https://api.github.com/users/Hakog/repos","events_url":"https://api.github.com/users/Hakog/events{/privacy}","received_events_url":"https://api.github.com/users/Hakog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-02-10T10:41:39Z","updated_at":"2016-08-12T14:01:39Z","closed_at":"2016-08-12T14:01:39Z","body":"Hi,\r\n\r\nAn `android.os.NetworkOnMainThreadException` is thrown when trying to connect. This exception is thrown only at Android 4.1.1 API level 16. Everything above Android 4.1.1 API level 16 seems to work fine. \r\n\r\nTested with version 1.3.4 of the plugin.\r\n\r\nShould the connect() method run on a seperate thread ? Or is this an issue on Android 4.1.1 only ? Or maybe i am doing something wrong ?\r\n\r\nI am using the plugin inside an ionic project.\r\n\r\nSomething like:\r\n```\r\n    window.chrome.sockets.tcp.create({}, function(createInfo) {\r\n      console.log('socket created ', JSON.stringify(createInfo));\r\n      window.chrome.sockets.tcp.connect(createInfo.socketId, '127.0.0.1', 8100, function(connectionInfo) {\r\n        console.log('socket connected ', JSON.stringify(connectionInfo));\r\n        var message = str2ab('hello world');\r\n        window.chrome.sockets.tcp.send(createInfo.socketId, message, function(sendInfo) {\r\n          console.log('Message send ', JSON.stringify(sendInfo));\r\n        });\r\n      });\r\n    });\r\n```\r\nComplete stacktrace:\r\n```\r\n\r\nE/PluginManager( 1228): android.os.NetworkOnMainThreadException\r\nE/PluginManager( 1228): \tat android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)\r\nE/PluginManager( 1228): \tat libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)\r\nE/PluginManager( 1228): \tat libcore.io.IoBridge.connectErrno(IoBridge.java:127)\r\nE/PluginManager( 1228): \tat libcore.io.IoBridge.connect(IoBridge.java:112)\r\nE/PluginManager( 1228): \tat libcore.io.IoBridge.connect(IoBridge.java:100)\r\nE/PluginManager( 1228): \tat java.nio.SocketChannelImpl.connect(SocketChannelImpl.java:168)\r\nE/PluginManager( 1228): \tat org.chromium.ChromeSocketsTcp$TcpSocket.connect(ChromeSocketsTcp.java:779)\r\nE/PluginManager( 1228): \tat org.chromium.ChromeSocketsTcp.connect(ChromeSocketsTcp.java:239)\r\nE/PluginManager( 1228): \tat org.chromium.ChromeSocketsTcp.execute(ChromeSocketsTcp.java:63)\r\nE/PluginManager( 1228): \tat org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:117)\r\nE/PluginManager( 1228): \tat org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)\r\nE/PluginManager( 1228): \tat org.apache.cordova.PluginManager.exec(PluginManager.java:133)\r\nE/PluginManager( 1228): \tat org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)\r\nE/PluginManager( 1228): \tat org.apache.cordova.CordovaBridge.promptOnJsPrompt(CordovaBridge.java:135)\r\nE/PluginManager( 1228): \tat org.apache.cordova.engine.SystemWebChromeClient.onJsPrompt(SystemWebChromeClient.java:124)\r\nE/PluginManager( 1228): \tat android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:655)\r\nE/PluginManager( 1228): \tat android.os.Handler.dispatchMessage(Handler.java:99)\r\nE/PluginManager( 1228): \tat android.os.Looper.loop(Looper.java:137)\r\nE/PluginManager( 1228): \tat android.app.ActivityThread.main(ActivityThread.java:4745)\r\nE/PluginManager( 1228): \tat java.lang.reflect.Method.invokeNative(Native Method)\r\nE/PluginManager( 1228): \tat java.lang.reflect.Method.invoke(Method.java:511)\r\nE/PluginManager( 1228): \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)\r\nE/PluginManager( 1228): \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)\r\nE/PluginManager( 1228): \tat dalvik.system.NativeStart.main(Native Method)\r\n```\r\n"}}
{"actor":{"display_login":"agrieve"}}