https icon indicating copy to clipboard operation
https copied to clipboard

android.os.NetworkOnMainThreadException

Open alromh87 opened this issue 7 years ago • 10 comments

Using this module on NS view-model i get NetworkOnMainThreadException, Im confused since documentation states:

  • Everything runs on a native background thread

Im using: https.enableSSLPinning({ host: '192.168.1.15', certificate, allowInvalidCertificates: false, validatesDomainName: false })

alromh87 avatar Mar 01 '18 05:03 alromh87

I am getting the same error. any Help?

skhye05 avatar May 03 '18 11:05 skhye05

+1

TinusJ avatar Jun 18 '18 10:06 TinusJ

+1

AresDev avatar Dec 13 '18 20:12 AresDev

+1

danielGz avatar Feb 05 '19 03:02 danielGz

@alromh87

import * as application from 'tns-core-modules/application'
application.android.on('activityCreated', function activityCreated(args) {
	android.os.StrictMode.setThreadPolicy(new android.os.StrictMode.ThreadPolicy.Builder().permitAll().build())
})

roblav96 avatar Mar 28 '19 15:03 roblav96

I wonder, whether there should be a correct implementation of the plugin. Since why this exception happens? If it really runs in the main thread, it might create a problem later. Are there any updates on it?

Update: And yeah, it proves I was right. Now I am working with http request with heavy response, about 30-40 mb (having attachments with base64 strs) at the moment. And it freezes dead the device, and if you attempt to refresh the list it then crashes with OutOfMemory exception. Any solution yet?

tokiroto avatar Jun 05 '19 06:06 tokiroto

@tokiroto nativescript works only on one main thread. For longer requests there will be a freeze or crash of the device.

Any solution for this problem thanks?

a92c avatar Mar 28 '20 16:03 a92c

This issue makes the plugin unusable.

jnorkus avatar Oct 22 '20 10:10 jnorkus

+1

vallemar avatar Nov 25 '21 22:11 vallemar

@vallemar could you explain a bit more what s happening for you?

farfromrefug avatar Nov 26 '21 08:11 farfromrefug