appwrite / functions-starter

31 stars 14 forks source link

🐛 Bug Report: Java Function - Host Is Unreachable #41

Open FuadEfendi opened 2 years ago

FuadEfendi commented 2 years ago

👟 Reproduction steps

Java Function:

    var client = new Client();
    client
        .setEndpoint("http://192.168.1.3/v1")
        .setProject("java0001")
        .setKey("...");
    var databases = new Databases(client);

Gradle:

dependencies {
    implementation 'io.appwrite:sdk-for-kotlin:1.1.0'
    implementation 'com.google.code.gson:gson:2.9.1'
    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.13.4'
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
    compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
    annotationProcessor 'org.projectlombok:lombok:1.18.24'
}
tasks.withType(Jar) { duplicatesStrategy = DuplicatesStrategy.INCLUDE }

NOTE: please document last line setting of this Gradle; otherwise it won't compile probably because of known Kotlin bug.

👍 Expected behavior

Can connect to database

👎 Actual Behavior

Different types of logs; I tried both, localhost and IP address:

An internal curl error has occurred within the executor! Error Msg: Host is unreachable
An internal curl error has occurred within the executor! Error Msg: Operation timed out
An internal curl error has occurred within the executor! Error Msg: Could not resolve host: java0001-6345a364024ea2ad902e

Last one is very strange because I use custom ID java0001.

🎲 Appwrite version

Version 1.0.x

💻 Operating system

MacOS

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

🏢 Have you read the Code of Conduct?

stnguyen90 commented 2 years ago

Thank you for raising this issue! 🙏 We’ll dig into this and get back to you as soon as we can. 😊

FuadEfendi commented 2 years ago

I was able to completely isolate the issue: implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.13.4' is conflicting dependency with com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.8.5 provided by "Open Runtimes" container (it is a subdependency of rapidoid HTTP server). So, expect similar non-documented surprises.

Unfortunately current architecture of Open Runtimes is miles far from typical Java containers (such as Tomcat) where for example Tomcat can provide MySQL driver version X.Y.Z, and web application will load and use JAR version from its' own WEB-INF/lib; plus, different applications do not clash with each other by using different conflicting dependencies.

Other related issues: hard (or impossible) to provide custom non-java files (such as property files, etc.); build will unpack all JARs and merge into single JAR and you can expect some classes clashing (and in this case check that you are not having duplicates); really hard to package non-Java configuration files since "parent" build.gradle is not part of Public API and we cannot manage it, only to some extent by "appending" our own deps.gradle.

Note that if I just have implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.13.4' in deps.gradle, with trivial "Hello, World" application, it will build and compile without issues other than you will be forced to have tasks.withType(Jar) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } in deps.gradle, but execution will fail without any clear message of what is going on, please review container.php to improve error handling / logging (as discussed in Discord).

Would be nice also to add Console Output so we can see Console in real time; button to "kill" hanging function; and etc.

Thank you!