Skip to content

Commit

Permalink
找到为什么客户端订阅多个主题后,发布其中一个主题,客户端出现错误的原因
Browse files Browse the repository at this point in the history
  • Loading branch information
zengang committed Nov 11, 2014
1 parent c8570fa commit 09d01ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/sub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit
while(clientMsg)
{
printf("timestamp:%d, state:%d, dup:%d\n",clientMsg->timestamp, (int)clientMsg->state, clientMsg->dup);
printf("msg:mid:%d,topic:%s,payload:%s,length:%d,qos:%d,retain:%d\n",clientMsg->msg.mid,clientMsg->msg.topic,clientMsg->msg.payload,\
clientMsg->msg.payloadlen,clientMsg->msg.qos,clientMsg->msg.retain);
//printf("msg:mid:%d,topic:%s,payload:%s,length:%d,qos:%d,retain:%d\n",clientMsg->msg.mid,clientMsg->msg.topic,clientMsg->msg.payload,\
clientMsg->msg.payloadlen,clientMsg->msg.qos,clientMsg->msg.retain); //这句导致出现订阅多个主题时客户端自动断开的现象
clientMsg = clientMsg->next;
}

Expand Down
1 change: 1 addition & 0 deletions src/mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ int main(int argc, char *argv[])

listener_max = -1;
listensock_index = 0;
printf("config.listener_count=%d,%s\n", config.listener_count, config.listeners[0].host);
for(i=0; i<config.listener_count; i++){
if(mqtt3_socket_listen(&config.listeners[i])){
_mosquitto_free(int_db.contexts);
Expand Down

0 comments on commit 09d01ea

Please sign in to comment.