Giter Club home page Giter Club logo

cocoamqtt's Introduction

CocoaMQTT

PodVersion Platforms License Swift version

MQTT v3.1.1 and v5.0 client library for iOS/macOS/tvOS written with Swift 5

Build

Build with Xcode 11.1 / Swift 5.1

IOS Target: 12.0 or above OSX Target: 10.13 or above TVOS Target: 10.0 or above

xcode 14.3 issue:

File not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a

If you encounter the issue, Please update your project minimum depolyments to 11.0

Installation

CocoaPods

To integrate CocoaMQTT into your Xcode project using CocoaPods, you need to modify you Podfile like the followings:

use_frameworks!

target 'Example' do
    pod 'CocoaMQTT'
end

Then, run the following command:

$ pod install

At last, import "CocoaMQTT" to your project:

import CocoaMQTT

Carthage

Install using Carthage by adding the following lines to your Cartfile:

github "emqx/CocoaMQTT" "master"

Then, run the following command:

$ carthage update --platform iOS,macOS,tvOS --use-xcframeworks

At last:

On your application targets “General” settings tab, in the "Frameworks, Libraries, and Embedded content" section, drag and drop CocoaMQTT.xcframework, CocoaAsyncSocket.xcframework and Starscream.xcframework from the Carthage/Build folder on disk. Then select "Embed & Sign".

Usage

Create a client to connect MQTT broker:

///MQTT 5.0
let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier)
let mqtt5 = CocoaMQTT5(clientID: clientID, host: "broker.emqx.io", port: 1883)

let connectProperties = MqttConnectProperties()
connectProperties.topicAliasMaximum = 0
connectProperties.sessionExpiryInterval = 0
connectProperties.receiveMaximum = 100
connectProperties.maximumPacketSize = 500
mqtt5.connectProperties = connectProperties

mqtt5.username = "test"
mqtt5.password = "public"
mqtt5.willMessage = CocoaMQTTMessage(topic: "/will", string: "dieout")
mqtt5.keepAlive = 60
mqtt5.delegate = self
mqtt5.connect()

///MQTT 3.1.1
let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier)
let mqtt = CocoaMQTT(clientID: clientID, host: "broker.emqx.io", port: 1883)
mqtt.username = "test"
mqtt.password = "public"
mqtt.willMessage = CocoaMQTTMessage(topic: "/will", string: "dieout")
mqtt.keepAlive = 60
mqtt.delegate = self
mqtt.connect()

Now you can use closures instead of CocoaMQTTDelegate:

mqtt.didReceiveMessage = { mqtt, message, id in
    print("Message received in topic \(message.topic) with payload \(message.string!)")           
}

SSL Secure

One-way certification

No certificate is required locally. If you want to trust all untrust CA certificates, you can do this:

mqtt.allowUntrustCACertificate = true

Two-way certification

Need a .p12 file which is generated by a public key file and a private key file. You can generate the p12 file in the terminal:

openssl pkcs12 -export -clcerts -in client-cert.pem -inkey client-key.pem -out client.p12

Note: Please use openssl version 1.1 (e.g. brew install [email protected]), otherwise you may not be able to import the generated .p12 file to the system correctly.

MQTT over Websocket

In the 1.3.0, The CocoaMQTT has supported to connect to MQTT Broker by Websocket.

If you integrated by CocoaPods, you need to modify you Podfile like the followings and execute pod install again:

use_frameworks!

target 'Example' do
    pod 'CocoaMQTT/WebSockets'
end

If you're using CocoaMQTT in a project with only a .podspec and no Podfile, e.g. in a module for React Native, add this line to your .podspec:

Pod::Spec.new do |s|
  ...
  s.dependency "Starscream"
end

Then, Create a MQTT instance over Websocket:

///MQTT 5.0
let websocket = CocoaMQTTWebSocket(uri: "/mqtt")
let mqtt5 = CocoaMQTT5(clientID: clientID, host: host, port: 8083, socket: websocket)
let connectProperties = MqttConnectProperties()
connectProperties.topicAliasMaximum = 0
// ...
mqtt5.connectProperties = connectProperties
// ...

_ = mqtt5.connect()

///MQTT 3.1.1
let websocket = CocoaMQTTWebSocket(uri: "/mqtt")
let mqtt = CocoaMQTT(clientID: clientID, host: host, port: 8083, socket: websocket)

// ...

_ = mqtt.connect()

If you want to add additional custom header to the connection, you can use the following:

let websocket = CocoaMQTTWebSocket(uri: "/mqtt")
websocket.headers = [
            "x-api-key": "value"
        ]
        websocket.enableSSL = true

let mqtt = CocoaMQTT(clientID: clientID, host: host, port: 8083, socket: websocket)

// ...

_ = mqtt.connect()

Example App

You can follow the Example App to learn how to use it. But we need to make the Example App works fisrt:

$ cd Examples

$ pod install

Then, open the Example.xcworkspace/ by Xcode and start it!

Dependencies

These third-party functions are used:

GCDAsyncSocket

LICENSE

MIT License (see LICENSE)

Contributors

Author

Twitter

https://twitter.com/EMQTech

cocoamqtt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cocoamqtt's Issues

CocoaMQTT Memory Leak?

Mail from Stolarski:

I’m using your library for the last few months, and In the last few days I’m trying to trace a memory leak in my app, which I believe is coming from the mqtt publisher.

When I’m looking at the memory allocations using apple’s leaks instrumentation tool, I can see a ContiguousArrayStorage is being allocated each time a message is being sent. This array doesn’t seem to be released during the app life, and because my app send messages every few minutes, it ends with ~600Kb being allocated every 2-3 minutes, which causes the app to crash eventually after few hours/days.

Error in connecting to socket

I am trying to connect a host with url tcp://172...** with port ***. but i am getting error 8 - "nodename nor servname provided, or not known". Please help.

Make CLI more useful / configurable

Right now, the sample code uses hard coded values. Would be helpful to make it into a more generic pub/sub utility using command-line parameters. Working on improving this.

Improvement: very long compile times on CocoaMQTTFrame.data()

Hi,

depending on your project philosophy this may be a non-issue (so feel free to close it), but with current Swift compiles we noticed that CocoaMQTTFrame.swift, func data() -> [UInt8](lines 159ff) take an exceptional amount of compile time (on my local machine about 10 seconds).

I think this is about the same issue (array concatenation) as mentioned in https://twitter.com/benjaminencz/status/685510563015741440 for example, the compile times can be easily reproduced as described in http://irace.me/swift-profiling

If you choose to accommodate this compiler issue, refactoring this method avoiding the plus operation on the array may remedy this issue and improve compile times considerably :-)

Disconnect on bad connection

I don't know if there is a bug or just a misunderstanding by my part.
When I connect over a bad 3G signal, in a while it stops receiving answers from ping ("pong").
In my opinion it should fire mqttDidDisconnect.
Is my understanding correct, or I have to implement a way to check that?

SSL connection with RabbitMQ

Hi all
Did you ever try to connect this MQTT client to a rabbitMQ instance using SSL?
I'm having a hard time doing so, maybe you have some suggestions
Here's the code I'm using:

    mqttClient = CocoaMQTT(clientId: "client", host: host, port: 8883)
    mqttClient?.secureMQTT = true
    mqttClient?.username = username
    mqttClient?.password = password
    mqttClient?.keepAlive = 90
    mqttClient?.delegate = self
    mqttClient?.connect()

This results in this error:

Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

The endpoint is working correctly, other clients (written in other languages) are working fine.
I was able to connect using ckrey/MQTT-Client-Framework, but I rather use this library instead :)

No IOS 7 support

Hi Guys,

First, thanks for building a neat Swift MQTT lib!
But is it really necessary to set the minimum IOS version to 8.0? There are still a lot of projects out there that support IOS 7. Of course, nobody wants to but there really are still some users out there. In our case, still 6% of all IOS users have IOS 7.x

I would be very grafeful if you could take a look and maybe decide to support 7.0
Otherwise I have to use a different (ObjC) lib.

Have a nice day!

does this framework support VOIP protocol?

When i push the home button of iPhone, app goes to background and the socket connection is closed. IOS support VIOP background module. APP use this module, IOS system can take over the socket connection when APP goes to background. When socket reveive something, IOS system wake app up for a moment to do with it.

About VIOP problem

Now, this framework is support VOIP and socket can keep connecting with server. But the didReceivedMessage delegate didn't response. When the app come back forground, then the delegate be called. It's not immediate.

Message ID

We encountered a bug with your _nextMessageId() function.
When it reaches the max value the whole app crashes.
We fixed this bug with rewriting your code:

CocoaMQTT.swift

func _nextMessageId() -> UInt16 {
        if amid == UInt16.max {
            amid = 0
        }
        amid += 1
        return amid
    }

Fails to compile in XCODE 6.4

Hello,

The code fails to compile in Xcode 6.4 with 19 errors all of which are in the file "CocoaMQTT.swift":

  • "Use of undeclared type 'GCDAsyncSocketDelegate'"
  • "Use of unresolved identifier 'GCDAsyncSocket'"
  • "'CocoaMQTT' does not have a member named 'socket'"
  • "'CocoaMQTTReader' does not have a member named 'socket'"

Any idea how to solve this?
EDIT: nvm solved it.

Why do you have another libraries in sandbox

Why you don't use it as dependency? I have a few frameworks which works with GCDAsynchSocket. And I have a problems when I use these libraries in one project. Can you add it as CocoaPod dependency?

Crash if server returns reserved CONNACK message

Background:
AdafruitIO has extended the MQTT protocol by adding two additional CONNACK return codes:

6: Connection Refused, throttled
7: Connection Refused, banned

https://io.adafruit.com/blog/mqtt/2016/06/28/extending-the-mqtt-protocol/

Under normal circumstances, these codes shouldn't come up. However, I have engineered my code to reconnect after a slight delay on disconnection. Due to #98 this code currently is being triggered frequently, leading to AdafruitIO throttling further connections.

Issue:
When the server returns a CONNACK message with a code other than the formally defined 0-5 (
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033 ), CocoaMQTT crashes in CocoaMQTT.didReceiveConnAck(reader:, connack:) at:

let ack = CocoaMQTTConnAck(rawValue: connack)!

The initializer for CocoaMQTTConnAck returns nil when passed a rawValue outside 0...5.

`fatal error: unexpectedly found nil while unwrapping an Optional value
2016-10-20 17:12:14.708461 Ahem[1782:42159] fatal error: unexpectedly found nil while unwrapping an Optional value
Current stack trace:
0    libswiftCore.dylib                 0x0000000100458580 swift_reportError + 132
1    libswiftCore.dylib                 0x0000000100475850 _swift_stdlib_reportFatalError + 61
2    libswiftCore.dylib                 0x0000000100271550 specialized specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) -> A + 355
3    libswiftCore.dylib                 0x00000001003e9600 partial apply for (_fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never).(closure #2) + 109
4    libswiftCore.dylib                 0x0000000100271550 specialized specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) -> A + 355
5    libswiftCore.dylib                 0x00000001003a4970 specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never + 96
6    CocoaMQTT                          0x00000001001b64e0 CocoaMQTT.didReceiveConnAck(CocoaMQTTReader, connack : UInt8) -> () + 149
7    CocoaMQTT                          0x00000001001b86d0 protocol witness for CocoaMQTTReaderDelegate.didReceiveConnAck(CocoaMQTTReader, connack : UInt8) -> () in conformance CocoaMQTT + 76
8    CocoaMQTT                          0x00000001001ba7c0 CocoaMQTTReader.frameReady() -> () + 440
9    CocoaMQTT                          0x00000001001ba220 CocoaMQTTReader.payloadReady(Data) -> () + 1403
10   CocoaMQTT                          0x00000001001b5250 CocoaMQTT.socket(GCDAsyncSocket, didRead : Data, withTag : Int) -> () + 4089
11   CocoaMQTT                          0x00000001001b62b0 @objc CocoaMQTT.socket(GCDAsyncSocket, didRead : Data, withTag : Int) -> () + 95
12   CocoaAsyncSocket                   0x0000000100133900 __37-[GCDAsyncSocket completeCurrentRead]_block_invoke + 83
13   libdispatch.dylib                  0x0000000100aac741 _dispatch_call_block_and_release + 12
14   libdispatch.dylib                  0x0000000100aa2fc4 _dispatch_client_callout + 8
15   libdispatch.dylib                  0x0000000100ab1a71 _dispatch_main_queue_callback_4CF + 362
16   CoreFoundation                     0x00007fff9eca9c80 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
17   CoreFoundation                     0x00007fff9ec6a810 __CFRunLoopRun + 2205
18   CoreFoundation                     0x00007fff9ec6a410 CFRunLoopRunSpecific + 420
19   HIToolbox                          0x00007fff9e20be7c RunCurrentEventLoopInMode + 240
20   HIToolbox                          0x00007fff9e20bbf1 ReceiveNextEventCommon + 432
21   HIToolbox                          0x00007fff9e20bb8f _BlockUntilNextEventMatchingListInModeWithFilter + 71
22   AppKit                             0x00007fff9c9021b0 _DPSNextEvent + 1093
23   AppKit                             0x00007fff9d012286 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1637
24   AppKit                             0x00007fff9c8f6c1f -[NSApplication run] + 926
25   AppKit                             0x00007fff9c8c15b5 NSApplicationMain + 1237
26   Ahem                               0x0000000100027750 main + 84
27   libdyld.dylib                      0x00007fffb3caa254 start + 1
`

It would be nice (and more future-safe as MQTT evolves) if CocoaMQTT could handle reserved values more gracefully. There may be other instances of this class of issue besides CONNACK.

Runtime error when it receives empty messages

When CocoaMQTT receives an empty messages it generates a runtime error on:

payload = [UInt8](data![pos...end])

In CocoaMQTTFramePublish:

    func unpack() {
        //topic
        var msb = data![0], lsb = data![1]
        let len = UInt16(msb) << 8 + UInt16(lsb)
        var pos: Int = 2 + Int(len)
        topic = NSString(bytes: [UInt8](data![2...(pos-1)]), length: Int(len), encoding: NSUTF8StringEncoding) as? String

        //msgid
        if qos == 0 {
            msgid = 0
        } else {
            msb = data![pos]; lsb = data![pos+1]
            msgid = UInt16(msb) << 8 + UInt16(lsb)
            pos += 2
        }
        //payload
        let end = data!.count - 1

        payload = [UInt8](data![pos...end])
    }

Message payload truncated

When receiving messages (from e.g. mosquitto_pub), the first two characters of the message body are being lost. Messages sent from another CocoaMQTT client are received intact.

Retained Messages

Is it possible to set the retained bit of of a published message to true?

It does't look look the the publish call includes a retained option.

no such moudle ’CocoaAsyncSocket

follow this step
$ git init
Add CocoaMQTT as a git submodule by running the following command:
$ git submodule add https://github.com/emqtt/CocoaMQTT.git

CocoaPods

Install using CocoaPods by adding this line to your Podfile:

use_frameworks! # Add this if you are targeting iOS 8+ or using Swift
pod 'CocoaMQTT'
Then, run the following command:

$ pod install
Last, creat a CocoaMQTT-Bridging-Header.h file in your project, in which add the following line:

import "CocoaMQTT/CocoaMQTT.h"

xcode 7.2
//
// CocoaMQTT.swift
// CocoaMQTT
//
// Created by Feng [email protected] on 14/8/3.
// Copyright (c) 2015 emqtt.io. All rights reserved.
//

import Foundation
import CocoaAsyncSocket --- no such moudle ’CocoaAsyncSocket ‘

import MSWeakTimer

two or more connections management

HI, could you please help with issue:

If I created 2 or more connections, how I can stop specific session ?
Maybe I can specify for example - mqtt!."Some unique identifier like a clientId or port".disconnect() ?

Resending messages which never received a PubAck

Currently it looks like when messages are given qos > 0, they are persisted in a Dictionary field named messages

https://github.com/emqtt/CocoaMQTT/blob/master/Source/CocoaMQTT.swift#L228-L242

This field is private and appears to be used for this and some QOS2 related concerns. However, as far as I can tell there isn't a mechanism to attempt to retry sending these messages, and since the field is private there isn't a way for users to do this in their apps.

Would it make sense to make the messages field public so that users could A. resend messages and B. show the status of messages to users?

Support IPv6 with non-standart port Issue

Hi, I have some issues trying to connect to my mqtt server with a domain name that returns an IPv4, and GCDAsyncSocket cant digest over an IPv6 network. I ran step by step to tried to figured out what's happened, and I think that maybe it is because I use an numeric port and the "getaddrinfo" cant resolve it.

Can you help me with this issue please, my app was rejected by Apple because of this.

Thanks in advance.

Unable to connect

I have a MQTT over WebSocket host with NodeRed. I am using this library in order to connect but I am getting the following error:

Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

Code:
let clientIdPid = "CocoaMQTT-" + String(NSProcessInfo().processIdentifier)
let mqtt = CocoaMQTT(clientId: clientIdPid, host: "95.177.135.232", port: 9001)
mqtt.cleanSess = true
mqtt.keepAlive = 60
mqtt.delegate = self
mqtt.connect()

Making `subscriptions` public

It would be nice if a client could track its subscriptions.
Better still, subscribing to already subscribed topics could be sort of a no-op with maybe an option for forced subscribe.

Currently, I'm doing this using a Set and the didSubscribeTopic & didUnsubscribeTopic callbacks.
Is there any plan to support this?

Error when subscribing to multiple topics

You should either make connState property public so a dev could check if already connected. If not here are the steps I took to get to the error below

  1. We have a few topics
  2. When I subscribe to first topic everything works
  3. When I want to subscribe to another topic. I am assuming that it automatically disconnects from the first topic internally because I stop receiving messages and start receiving messages from new inserted topic
  4. Now if I try to connect to that first topic I get the error message below crash.

I would disconnect to the first topic if connState was available.

assertion failed: : file /Pods/CocoaMQTT/Source/CocoaMQTT.swift, line 581

import CocoaMQTT dont work

i'am using xcode 8.1 and Swift 10.1.
i did pod install and i it was installed la version 1.0; Is it correct ?
Well, when i put the import CocoaMQTT at code, the xcode say No Such Module.

What is happening ?

Thanks

Using the framework of the mistakes in the oc

1.Install CocoaMQTT using CocoaPods
2.Choose the OC project
3.Choose the project name in the TARGETS list
4.Click the Build Settings tab
5.In the Build Options section, make sure the option Embedded Content Contains Swift Code is YES, and Defines Module is YES
6.Now, you can import CocoaMQTT framework into any Objective-C .m like: @import CocoaMQTT;

According to the above method in the oc use this frame the following mistakes,How to solve?
2016-03-07 10 14 09

CocoaMQTT does not work with moquette and HiveMQ on IOS

Hello

It seems like CocoaMQTT does not send standard messages. I tested it with 2 mqtt brokers and I got the some no response. Here it is what I did.

I wrote this code (that is basically the same code in main.swift):

    let mqtthost = "10.0.0.10" // the ip address of the mqtt broker.
    let mqttCli = CocoaMQTTCli()
    let clientIdPid = "CocoaMQTT-" + String(NSProcessInfo().processIdentifier)
    let mqtthost = "24.25.1.31"
    let mqtt = CocoaMQTT(clientId: clientIdPid, host: mqtthost, port: 1883)
//    mqtt.username = "test"
//    mqtt.password = "public"
    mqtt.willMessage = CocoaMQTTWill(topic: "/will", message: "dieout")
    mqtt.keepAlive = 90
    mqtt.delegate = mqttCli
    let connected = mqtt.connect()
    NSLog("Connected \(connected)")
    mqtt.subscribe("/a/b/c", qos: CocoaMQTTQOS.QOS1)
    mqtt.publish("/a/b/c", withString: "Qos0 Msg", qos: CocoaMQTTQOS.QOS0)
    mqtt.publish("/a/b/c", withString: "Qos1 Msg", qos: CocoaMQTTQOS.QOS1)
    mqtt.publish("/a/b/c", withString: "Qos2 Msg", qos: CocoaMQTTQOS.QOS2)
    mqtt.ping()

Client console output is:

Hello, CocoaMQTT!
2015-10-18 13:21:36.075 thought you[20155:1236000] Connected true
didPublishMessage to /a/b/c
didPing

The IOS application never receives messages. It could send but they are never published. I launched a moquette broker instance on localhost. Here is mqtt output:


  ___  ___                       _   _        ___  ________ _____ _____  
  |  \/  |                      | | | |       |  \/  |  _  |_   _|_   _| 
  | .  . | ___   __ _ _   _  ___| |_| |_ ___  | .  . | | | | | |   | |   
  | |\/| |/ _ \ / _\ | | | |/ _ \ __| __/ _ \ | |\/| | | | | | |   | |   
  | |  | | (_) | (_| | |_| |  __/ |_| ||  __/ | |  | \ \/' / | |   | |   
  \_|  |_/\___/ \__, |\__,_|\___|\__|\__\___| \_|  |_/\_/\_\ \_/   \_/   
                   | |                                                   
                   |_|                                                   

0    [main] INFO  Server  - Using config file: /Users/pablo/Downloads/distribution-0.7-bundle-tar/config/moquette.conf
5    [main] INFO  Server  - Persistent store file: /Users/pablo/Downloads/distribution-0.7-bundle-tar/bin/moquette_store.mapdb
174  [main] INFO  FileAuthenticator  - Loading password file: /Users/pablo/Downloads/distribution-0.7-bundle-tar/config/password_file.conf
405  [main] INFO  NettyAcceptor  - Server binded host: 0.0.0.0, port: 1883
408  [main] INFO  NettyAcceptor  - Server binded host: 0.0.0.0, port: 8080
Server started, version 0.7
7401 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type SUBSCRIBE
7402 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PUBLISH
7402 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PUBLISH
7402 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PUBLISH
7403 [pool-1-thread-1] ERROR SimpleMessaging  - Serious error processing the message org.eclipse.moquette.proto.messages.SubscribeMessage@7517ce04 for session [clientID: null]org.eclipse.moquette.server.netty.NettyChannel@30155ec2
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.moquette.spi.impl.AnnotationSupport.dispatch(AnnotationSupport.java:66)
    at org.eclipse.moquette.spi.impl.SimpleMessaging.onEvent(SimpleMessaging.java:173)
    at org.eclipse.moquette.spi.impl.SimpleMessaging.onEvent(SimpleMessaging.java:62)
    at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.moquette.spi.impl.AnnotationSupport.dispatch(AnnotationSupport.java:64)
    ... 6 more
Caused by: java.lang.NullPointerException
    at org.eclipse.moquette.spi.impl.ProtocolProcessor.processSubscribe(ProtocolProcessor.java:606)
    ... 11 more
7412 [pool-1-thread-1] INFO  ProtocolProcessor  - PUBLISH from clientID <null> on topic </a/b/c> with QoS MOST_ONE
7413 [pool-1-thread-1] INFO  ProtocolProcessor  - PUBLISH from clientID <null> on topic </a/b/c> with QoS LEAST_ONE
7406 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PINGREQ
7424 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type CONNECT
7495 [pool-1-thread-1] ERROR ProtocolProcessor  - 
java.lang.RuntimeException: Can't find a ConnectionDescriptor for client null in cache {}
    at org.eclipse.moquette.spi.impl.ProtocolProcessor.sendPubAck(ProtocolProcessor.java:476)
    at org.eclipse.moquette.spi.impl.ProtocolProcessor.executePublish(ProtocolProcessor.java:324)
    at org.eclipse.moquette.spi.impl.ProtocolProcessor.processPublish(ProtocolProcessor.java:301)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.moquette.spi.impl.AnnotationSupport.dispatch(AnnotationSupport.java:64)
    at org.eclipse.moquette.spi.impl.SimpleMessaging.onEvent(SimpleMessaging.java:173)
    at org.eclipse.moquette.spi.impl.SimpleMessaging.onEvent(SimpleMessaging.java:62)
    at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
7498 [pool-1-thread-1] INFO  ProtocolProcessor  - PUBLISH from clientID <null> on topic </a/b/c> with QoS EXACTLY_ONCE
7501 [pool-1-thread-1] ERROR SimpleMessaging  - Serious error processing the message org.eclipse.moquette.proto.messages.PublishMessage@341cb737 for session [clientID: null]org.eclipse.moquette.server.netty.NettyChannel@72bcc5ea
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.moquette.spi.impl.AnnotationSupport.dispatch(AnnotationSupport.java:66)
    at org.eclipse.moquette.spi.impl.SimpleMessaging.onEvent(SimpleMessaging.java:173)
    at org.eclipse.moquette.spi.impl.SimpleMessaging.onEvent(SimpleMessaging.java:62)
    at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.moquette.spi.impl.AnnotationSupport.dispatch(AnnotationSupport.java:64)
    ... 6 more
Caused by: java.lang.NullPointerException
    at org.eclipse.moquette.spi.impl.ProtocolProcessor.sendPubRec(ProtocolProcessor.java:459)
    at org.eclipse.moquette.spi.impl.ProtocolProcessor.executePublish(ProtocolProcessor.java:330)
    at org.eclipse.moquette.spi.impl.ProtocolProcessor.processPublish(ProtocolProcessor.java:301)
    ... 11 more
7517 [pool-1-thread-1] INFO  ProtocolProcessor  - cleaning old saved subscriptions for client <CocoaMQTT-20155>
7533 [pool-1-thread-1] INFO  ProtocolProcessor  - Create persistent session for clientID <CocoaMQTT-20155>
7573 [pool-1-thread-1] INFO  ProtocolProcessor  - Connected client ID <CocoaMQTT-20155> with clean session true
97566 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PINGREQ
187576 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PINGREQ
277573 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PINGREQ
367575 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PINGREQ
457575 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PINGREQ
547579 [nioEventLoopGroup-3-1] INFO  NettyMQTTHandler  - Received a message of type PINGREQ

Running the example project fails

I downloaded and ran the example project on an iPhone 5. But it fails with the following error.

dyld: Library not loaded: @rpath/CocoaAsyncSocket.framework/CocoaAsyncSocket
Referenced from: /private/var/containers/Bundle/Application/F1106E5F-A377-49BC-B09D-5BB5BDB4FD0D/Example.app/Frameworks/CocoaMQTT.framework/CocoaMQTT
Reason: image not found

Swift 2.3

Is there a version to use CocoaMQTT with Swift 2.3? As far as I can tell, the current version only works for Swift 3.0 right?

Assertion Causes Crash?

Inside CocoaMQTT.swift, in the frameReady() function, on the switch function if the frameType is undetermined there is a force crash with assert(false).

My app is sometimes crashing on this (I can't figure out what's causing this as it does not happen all the time).

I'm not sure if this is an issue with the library or my implementation, do you have any thoughts on this?

Other than this issue, the MQTT library seems to be working perfectly.

Cannot build watchOS and OSX schemes

I tried to build all the schemes of the project to get it ready for Carthage. But I couldn't do that for two of the schemes: watchOS and OSX.

There's an error for the watchOS target:

/Users/user/Projects/CocoaMQTT/Source/CocoaMQTT.swift:291:32: Use of unresolved identifier 'kCFStreamSSLPeerName'

And another one for OSX:

/Users/user/Projects/CocoaMQTT/Source/CocoaMQTT.swift:284:33: Value of type 'GCDAsyncSocket' has no member 'enableBackgroundingOnSocket'

As I don't need those schemes for my project now I didn't go deep into those errors. But I think it's important to state them here. I used Xcode Version 7.2.1 (7C1002) for building. There'd been no changes made to the project prior to building.

Carthage update fails

Hi,
I've been trying to integrate CocoaMQTT with my project. Carthage update fails. Use Legacy Swift Language Version flag needs to be set to YES.

The delegate of publish message

The delegate of publish message is from client, not from server. How can figure out the message state? did server received or not?

Fails to compile in Swift 1.2

A number of issues e.g. unknown type of Byte, and some ambiguous operators e.g. += - also implicit type conversions and other problems. Working on a patch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.