Skip to content

failed to establish tcp connection on session connect #61

@jrobsonchase

Description

@jrobsonchase

This is somewhat blocked by #50, since failing to load via the NativeSession's static block will prevent the runtime from getting initialized properly, which blocks everything else.

However, if you follow the suggested approach from #54 and copy the .so into your android project's JNI libs folder and load the library ahead of time, you can almost make it work. You still need to move the call to Runtime.init out of the try block where Runtime.load throws an exception.

Anyway, if you get all that accomplished, you can successfully call into Rust, which presents you with this lovely stack trace:

java.io.IOException: failed to establish tcp connection
	at com.ngrok.NativeSession.connectNative(Native Method)
	at com.ngrok.NativeSession.connect(NativeSession.java:46)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.ngrok.Session.connect(Session.java:47)
	at com.ngrok.Session$Builder.connect(Session.java:542)
	at com.example.myapplication.MainActivity.onCreate(MainActivity.kt:24)
	at android.app.Activity.performCreate(Activity.java:8780)
	at android.app.Activity.performCreate(Activity.java:8752)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1475)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4067)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4243) 
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:114) 
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:144) 
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:101) 
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2705) 
	at android.os.Handler.dispatchMessage(Handler.java:106) 
	at android.os.Looper.loopOnce(Looper.java:255) 
	at android.os.Looper.loop(Looper.java:364) 
	at android.app.ActivityThread.main(ActivityThread.java:8938) 
	at java.lang.reflect.Method.invoke(Native Method) 
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572) 
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1053) 

Not super informative, but hacking up ngrok-java-native to stuff more context into that error tells us: failed to establish tcp connection to connect.ngrok-agent.com: failed to lookup address information: No address associated with hostname

Soooo DNS isn't working right? That's about as far as I've gotten. Possibly some nuance of android app networking that I'm not aware of, or maybe a bad system resolver being used by the rust lib?

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions