← Back to team overview

mosquitto-users team mailing list archive

Re: Mosquitto+Python+MySQL+APNS

 

for the "client" you are talking about here, just want to make sure i
understand correctly:

what i should do is:

1. just run a *regular *broker as the original mosquitto broker on the
server side.* I should not modify it at all;*
2. meanwhile, i should implement a *special client* on the *server
side, *adding
the database saving functionality to it;
3. for all the messages received by the broker, the special client will
subscribe/receive it and store it to the database;
4. the broker will distribute the message to all the regular subscribers on
mobile client side.(should I add the database storing method on the mobile
mosquitto client, depending on do i need to do the same database saving
thing on mobile)

so the sole purpose of the *special client* on the server side is just
"saving the messages to database".


-Horace

On Tue, Sep 18, 2012 at 4:54 PM, Roger Light <roger@xxxxxxxxxx> wrote:

> Hi Yun,
>
> > 1. what's the best practice to connect Mosquitto broker with the MySQL to
> > make sure: all messages are stored in the database? Ideally, all message
> > sent to server should be stored in the db before they are distributed, to
> > ensure the data security.
>
> At the moment you have to write an MQTT client that subscribes to the
> appropriate topics and then stores the messages in your database. You
> can ensure the messages are stored in the database before being
> distributed by carefully separating the topics that clients publish
> and subscribe to. Your server side processing then acts as in the
> "subscribe, receive, process, republish" pattern - it receives the
> incoming message, saves it to the database and then republishes it to
> the appropriate recipients. You could even split this up - one (or
> more, depending on how you arrange it) server side client for
> processing the incoming messages and saving them to the database, then
> other server side clients to distribute the messages.
>
> > 2. when the server know one client is not active/connected, the server
> > should call the APNS service to send the notice to the client. Should
> this
> > process happen in the API or from the broker?
>
> This is where you will want to make use of the "last will and
> testament" (or just "will") feature. When your client connects, it
> sets up a Will message with the broker. When the client disconnects
> unexpectedly (i.e. without sending a DISCONNECT) the broker publishes
> the Will. A common way of using this is to publish "1" to a topic e.g.
> status/<client id> when the client connects. The client also set up
> the Will to publish a "0" to status/<client id> on unexpected
> disconnect. Your server side processing can then subscribe to status/#
> to determine the current connection status of all clients and use this
> information for determining how to distribute the message.
>
> > 3. for the iPhone wrapper of the mosquitto client, I checked Marquette ,
> is
> > this wrapper compatible with the latest version of Mosquitto 1.0.2
>
> From what I can see, the last commit to Marquette was 8 months ago, so
> unfortunately no it isn't compatible with 1.0.2. I would point out
> that libmosquitto compiles just fine under Objective C, although of
> course it isn't an Objective C interface.
>
> Cheers,
>
> Roger
>
> > I know this is quite complicated issue, but really hope can get some
> advice
> > on how to approach.
> >
> > thanks a lot!
> >
> > -Horace
> >
> > --
> > Mailing list: https://launchpad.net/~mosquitto-users
> > Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~mosquitto-users
> > More help   : https://help.launchpad.net/ListHelp
> >
>

Follow ups

References