Giter Club home page Giter Club logo

mqtt'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

mqtt's Issues

mqtt.c发送函数源码一个bug

mqtt.c中一个函数:
int Mqtt_SendPkt(struct MqttContext *ctx, const struct MqttBuffer *buf, uint32_t offset)
{
const struct MqttExtent *cursor;
const struct MqttExtent *first_ext;
uint32_t bytes;
int ext_count;
int i;
struct iovec *iov;

if(offset >= buf->buffered_bytes) {
    return 0;
}

cursor = buf->first_ext;
bytes = 0;
while(cursor && bytes < offset) {
    bytes += cursor->len;
    cursor = cursor->next;
}

first_ext = cursor;
ext_count = 0;
for(; cursor; cursor = cursor->next) {
    ++ext_count;
}

if(0 == ext_count) {
    return 0;
}

assert(first_ext);

iov = (struct iovec*)malloc(sizeof(struct iovec) * ext_count);
if(!iov) {
    return MQTTERR_OUTOFMEMORY;
}

iov[0].iov_base = first_ext->payload + (offset - bytes);
iov[0].iov_len = first_ext->len - (offset - bytes);

i = 1;
for(cursor = first_ext->next; cursor; cursor = cursor->next) {
    iov[i].iov_base = cursor->payload;
    iov[i].iov_len = cursor->len;
    ++i;
}

i = ctx->writev_func(ctx->writev_func_arg, iov, ext_count);
free(iov);

return i;

}
这个部分有问题:
while(cursor && bytes < offset) {
bytes += cursor->len;
cursor = cursor->next;
}
当bytes>offset时,cursor不应该再进行移动,也不应该再进行字节增加所以应该为:
while(cursor&& bytes < offset) {
if(bytes+ cursor->len>offset)break;
bytes += cursor->len;
cursor = cursor->next;
}

疑似发现 OneNET Server 的 bug

Hi,

发现一个 bug,不过不是本仓库的 bug,而是你们 OneNET 服务端的 bug,不知道在哪里报 bug,就直接写在这里了。

下面是 MQTT v3.1.1 协议的原话 【链接

3.2.2.2 Session Present 

Position: bit 0 of the Connect Acknowledge Flags. 

If the Server accepts a connection with CleanSession set to 1, the Server MUST set Session Present to 0 in the CONNACK packet in addition to setting a zero return code in the CONNACK packet [MQTT-3.2.2-1].

但是事实上,当我发送了一个 CleanSession 为 1 的 CONNECT 消息时,接收到的 CONNACK 消息的 Session Present 字段却为 1。

我的 CONNECT消息的内容是:

0x10 0x25 0x0 0x4 0x4d 0x51 0x54 0x54 0x4 0xc2 0x0 0x0 0x0 0x7 0x35 0x36 0x31 0x39 0x31 0x30 0x39 0x0 0x5 0x38 0x35 0x35 0x37 0x34 0x0 0x9 0x68 0x65 0x6c 0x6c 0x6f ......

我接收到的 CONNACK 消息却是:

0x20 0x02 0x01 0x00

正确的 CONNACK 消息应该是:

0x20 0x02 0x00 0x00

希望你们验证一下,然后给我一个回复

PS: 应该是我之前某个时候,发送过 CleanSession=0 的连接,从而导致你们记住了 Session。

mqtt部分有个地方有问题,麻烦确认下?

mqtt.c
Mqtt_PackConnectPkt 函数中, id_len 定义是uint16_t,后面使用这个变量进行小于0的比较

id_len = Mqtt_CheckClentIdentifier(id); //这条语句是有可能返回-1的,判断会有问题
if(id_len < 0) {
return MQTTERR_ILLEGAL_CHARACTER;
}
具体上下文没有看,编译警告发现的,在基于开发板的SDK移植实例(MQTT)下面提供的工程源码中有调用该方法,并且具有相同的错误

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.