Standalone Watch App using Mqtt

For my project I'm planning to connect my app to a server an getting JSON-data from there using mqtt, without any phone connected. Both, Watch and Mqtt-Broker will be in the same local network. Will this be possible with WatchOS6, or did anyone already tried this?


PS: I know about the problem running mqtt in the background on iOS and I guess, this problem will be there on the watch also, but at moment, I don't care about that.

Replies

I tried doing this. It works with the emulator but I get this error when I try to deploy the app on an actual watch:



2019-06-27 14:15:17.089759-0400 MqttTestApp WatchKit Extension[253:46099] Use TLS

2019-06-27 14:15:18.026889-0400 MqttTestApp WatchKit Extension[253:46230] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1

2019-06-27 14:15:19.029427-0400 MqttTestApp WatchKit Extension[253:46230] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2

2019-06-27 14:15:20.031918-0400 MqttTestApp WatchKit Extension[253:46230] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3

2019-06-27 14:15:21.033430-0400 MqttTestApp WatchKit Extension[253:46230] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:5 Err:-1 Errno:1 Operation not permitted

2019-06-27 14:15:21.033736-0400 MqttTestApp WatchKit Extension[253:46230] [] nw_resolver_create_dns_service_locked [C1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)

2019-06-27 14:15:21.038004-0400 MqttTestApp WatchKit Extension[253:46302] [] nw_connection_get_connected_socket [C1] Client called nw_connection_get_connected_socket on unconnected nw_connection

2019-06-27 14:15:21.038177-0400 MqttTestApp WatchKit Extension[253:46302] TCP Conn 0x1463f390 Failed : error 0:-65563 [-65563]


Can somebody please let me know how to fix this?

I am trying to integrate MQTT in Apple Watch but trying it through Cocoapods gives me an error saying "watchos2 not supported".

I am having an iPhone app which is running smooth with MQTT using cocoapods when the app is open. But when I try to send data from the watch to iPhone when the iPhone is locked - nothing happens. So I have decided to implement MQTTChat at watch side too but when I try to implement it through cocoapods it gives me an error as not supported for watchos2. Also when I try through dropping files or framework it gives me many errors as cfnetwork not supported missing file .h and likewise. So can you guys help me by providing any cocoapods which supports Apple WatchOS 2 or some files or framework which can help me in integrating MQTT in apple watch? Thanks

My scenario is a little bit different, I'm using NWBrowser with a TCP Bounjour service on watchOS 6.1.
Upon calling start I have these errors:

2019-10-31 22:32:53.236903-0300 MyApp WatchKit Extension[401:255915] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:6 Err:-1 Errno:1 Operation not permitted
2019-10-31 22:32:53.237095-0300 MyApp WatchKit Extension[401:255915] [] nw_browser_fail_on_dns_error_locked [B0] nw_resolver_instantiate_dns_connection_for_parameters failed: ServiceNotRunning(-65563)

And symptoms are the same, simulator works but device doesn't.

Looking at this other question makes me wonder if the problem is entitlement wise: https://forums.developer.apple.com/message/270145#270145.