calimero-project / introduction

Code examples and additional documentation for using Calimero
20 stars 15 forks source link

CreateTunnelingLink not connecting #6

Closed AlexMun86 closed 3 years ago

AlexMun86 commented 3 years ago

Hi, I've tried this simple code to connect to my server. But I can't figure it out. Always getting this error: from /192.168.10.5:3671 to /192.168.10.13:3671: bind failed: EADDRNOTAVAIL (Cannot assign requested address) . What could be the problem?

bmalinowsky commented 3 years ago

Are you sure your local endpoint actually has an ip address of 192.168.10.5? This is a typical error code if the address does not exist.

What happens if you leave local = new InetSocketAddress(0) as is the default?

AlexMun86 commented 3 years ago

Yes, if it is the local IP on the computer? But when I set it local = new InetSocketAddress(0); I get this error: 2021-05-24 15:28:12.752 16205-16205/com.example.myapplication8 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication8, PID: 16205 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication8/com.example.myapplication8.MainActivity}: android.os.NetworkOnMainThreadException And the app crashes.

bmalinowsky commented 3 years ago

Ah, android. You cannot do network access on the ui thread. You have to use a dedicated thread, async task etc.

AlexMun86 commented 3 years ago

Ok, is there any example on this here? Async task is deprecated in Android I think.

bmalinowsky commented 3 years ago

No there aren't.

AlexMun86 commented 3 years ago

Ok, I thought Calimero could be used in Android Studio. But then I should find another solution.