Comments (19)
Thank you, I will try to find the problem as soon as possible
from kmqtt.
Hello, JitPack cannot provide the dependencies for Apple targets, I should update the Readme to let the users know. Anyway you can clone the repository, build it and publish it to maven local through Gradle. Then you can add maven local in the repositories of your project in build.gradle and you should be able to use the iOS dependencies. Keep in mind it's not been tested yet as I don't have Apple devices as of now.
from kmqtt.
Hey, thanks for the reply. I've ended up exploring a little bit the project and doing that afterwards. I was able to integrate it on my project but I didn't succeed to connect the MQTT Client (I'm using HiveMQ for the test). Anyways, I'll probably need to take a deep look on the code since I really wanted to integrate it in my project.
from kmqtt.
You can let me know what exactly is happening, so we can work together to solve the problem. I'm interested in expanding the supported platforms as much as possible. As I said I wasn't able to test the iOS implementation, but it's the same as on other POSIX platforms.
from kmqtt.
Sorry, I should have done that on my previous comment.
The error that is being retrieved is: kotlin.Exception: CONNACK not received in 30 seconds
This is my implementation:
val client = MQTTClient(
mqttVersion = 5,
address = "broker.mqttdashboard.com",
port = 8000,
tls = null,
webSocket = true,
clientId = "clientId-myClientAsGhYi",
) {
print("## rjfc ## - ${it.payload?.toByteArray()?.decodeToString()}")
}
client.subscribe(
listOf(
Subscription(
topicFilter = "my_custom_topic",
SubscriptionOptions(Qos.EXACTLY_ONCE)
)
)
)
client.publish(
false,
Qos.EXACTLY_ONCE,
"my_custom_topic",
"hello from KMM".encodeToByteArray().toUByteArray()
)
client.run()
I would be happy to help you in that task, since I can provide support regarding Apple dependencies.
from kmqtt.
So it looks like the connection is setup correctly but the CONNACK packet doesn't get sent by the server or received. It would be interesting if you could try without websockets first. Or maybe you could even try to setup mosquitto on your computer and try to connect to it from the phone on your local network, so that you can run wireshark or a similar tool and get a packet trace to see exactly what is happening.
from kmqtt.
I've tried without websockets and the result was the same: kotlin.Exception: CONNACK not received in 30 seconds
I've also done the Mosquitto procedure like you suggested and I was able to connect, subscribe and publish to my local network successfully.
from kmqtt.
Can you also try on test.mosquitto.org?
I have tried to use your exact code on Windows, to check if it was a problem with HiveMQ specifically, but it's working fine. Another option would be to run the code in the emulator (if possible) with Wireshark on the host to check what is happening to the TCP connection. Maybe the CONNECT packet is not even sent for some reason.
from kmqtt.
Same error on test.mosquitto.org: kotlin.Exception: CONNACK not received in 30 seconds
But this time, an interesting response. I didn't connect to test.mosquitto.org through my simulator (for some reason it was not recognising the host, giving me the error Socket connection failed: failed resolving address.
) but I used my local Mosquitto server. The given error was the same (kotlin.Exception: CONNACK not received in 30 seconds
) but this was what I could sniff on the Wireshark:
Comparing with the previous sniff I sent, looks like he is trying to subscribe before connect ACK but I don't really know if that could be the issue. Therefore, he is not succeeding at writing the topic and the message.
This was what I got from the server logs:
As you can see, at some point he connects with success but closes the connection after the 30 seconds. So, my guess would be that he can somehow communicate with the server but not receive any content from it.
from kmqtt.
You could try removing the subscribe
and publish
calls before callind run
in your code, so the client will only try to connect. This way we should be able to tell if indeed the problem is the subscribe before the connack. Sending packets before receiving the connack is not a protocol violation, and indeed the server isn't closing the connection. It looks like the client is not reading correctly the data sent by the server. This could be a problem with my specific iOS implementation of the POSIX calls.
from kmqtt.
Removed the subscribe and publish and the issue remains. The logs keep telling that the client was able to connect and after the 30 seconds the client closes the connection. In the app, the CONNACK error remains as well.
from kmqtt.
Please try to clone the latest version and see if it's working correctly. I was able to test on macosX64 and I got the same problem, which is now solved. I'm hoping you could try it on iOS too.
from kmqtt.
Thanks for taking a look into it. I've tried it and now I have a different issue:
It happened when I tried the tool with websockets and without it (locally). Wireshark didn't give much of information but this is what was shown as a log in the local server:
from kmqtt.
Error 54 is connection reset by peer, so the broker is closing the connection because of the malformed packet. Are you sure you are matching the MQTT version between client and broker? This could be because the broker uses MQTT 3.1.1 and you are trying to connect with MQTT 5 for example.
from kmqtt.
Yap, you're totally correct. I forgot completely that and I made the test without having that in mind (MQTT newbie here). I'll test it as soon as I can and give you some feedback again.
from kmqtt.
Sorry for the delay but I ended up not having time to give you some feedback until today. However, I've noticed that you have added TLS support! Thanks for that! 🙏🏼
I ended up updating the repo but I'm facing another issue:
❌ Error Log
> Task :shared:kspKotlinIosArm64 FAILED
e: Could not find "openssl-ios-arm64" in [/Users/<my-user>/dashtt-shared/shared, /Users/<my-user>/.konan/klib, /Users/<my-user>/.konan/kotlin-native-prebuilt-macos-x86_64-1.8.10/klib/common, /Users/<my-user>/.konan/kotlin-native-prebuilt-macos-x86_64-1.8.10/klib/platform/ios_arm64]
> Task :shared:kspKotlinIosArm64 FAILED
e: Could not find "openssl-ios-arm64" in [/Users/<my-user>/dashtt-shared/shared, /Users/<my-user>/.konan/klib, /Users/<my-user>/.konan/kotlin-native-prebuilt-macos-x86_64-1.8.10/klib/common, /Users/<my-user>/.konan/kotlin-native-prebuilt-macos-x86_64-1.8.10/klib/platform/ios_arm64]
Execution failed for task ':shared:kspKotlinIosArm64'.
> Compilation finished with errors
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Execution failed for task ':shared:kspKotlinIosArm64'.
> Compilation finished with errors
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
I suspect that the cause may be the fact that, in your openssl.def, you are pointing to your root files. Could you take a look on this?
Thanks in advance!
from kmqtt.
The def file is just to build OpenSSL. The library should be directly in the KMQTT dependency you are including in your project. Did you recompile KMQTT after updating it and published it to maven local? If yes, then please copy this file https://github.com/davidepianca98/KMQTT/blob/master/kmqtt-common/src/nativeInterop/openssl-ios-arm64.klib to one of the folders in the error while I try to find the problem.
from kmqtt.
Yap, I've done that but it's not working as well. This is what it retrieves me:
> Task :shared:linkDebugFrameworkIosArm64 FAILED
e: /Users/<my-user>/.gradle/caches/modules-2/files-2.1/com.github.davidepianca98/kmqtt-common-iosarm64/0.4.1/bb81191f70669a5e7a4d32c5fbcd289db7348a41/kmqtt-common is going to be cached, but its dependency isn't: /Users/<my-user>/<my-project>/openssl-ios-arm64
/Users/<my-user>/.gradle/caches/modules-2/files-2.1/com.github.davidepianca98/kmqtt-common-iosarm64/0.4.1/bb81191f70669a5e7a4d32c5fbcd289db7348a41/kmqtt-common is going to be cached, but its dependency isn't: /Users/<my-user>/<my-project>/openssl-ios-arm64
Execution failed for task ':shared:linkDebugFrameworkIosArm64'.
> Compilation finished with errors
from kmqtt.
I was able to reproduce the problem, but it's not clear why the library isn't getting included. To solve the second error (after copying the library to one of those directories) you can temporarily add this to your gradle.properties
:
kotlin.native.cacheKind.iosX64=none
kotlin.native.cacheKind.iosArm64=none
kotlin.native.cacheKind.iosSimulatorArm64=none
from kmqtt.
Related Issues (20)
- Can we use it in Android App as a background process? HOT 1
- Suggestions HOT 7
- Can we compile this code for android and iOS ? HOT 1
- HTTP header matching should be case insensitive to support more clients HOT 2
- Kotlin native could not find "openssl" HOT 8
- Can't use client library for macos arm 64 HOT 4
- Recurring crash of Client on JVM HOT 1
- Seeking help HOT 1
- Can't subscribe to topics after invoking client.run() HOT 5
- Unable to import MQTTClient in KMM project HOT 4
- connect to activemq HOT 6
- no default value for publishReceived
- callback for connect / disconnect & manage LWT HOT 2
- Artifact publication on Maven Central? HOT 3
- iOSBuild failed with Could not find 'openssl-its-simulator-arm64' HOT 2
- ssl server certificate not found (IOS only) HOT 4
- Failing to compile with Kotlin and Gradle KTS HOT 4
- "Unable to parse TLS packet header"-error caused by 0-byte-channel-read HOT 4
- Username and Password in the PacketInterceptor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kmqtt.