How to configure ZNC backlog for multiple clients

The znc IRC bouncer is a great piece of software. In this post, I’ll explain how to get individual backlog/buffer playback for each client.

The problem

The Auto Clear Chan Buffer and Auto Clear Query Buffer options, if checked, make sure that you receive backlog playback only once (instead of every time you connect). This however is not very useful if you use multiple clients and want to see all conversations on all of them, because only the first client to connect will receive the backlog. Leaving said options unchecked is not advisable either, since it will make ZNC send you the same backlog again and again, every time you connect. In both cases, it will only record backlog while no client is connected.

Example 1

You talk to someone from your computer at work, then you quit that client, go home and connect with your own computer. You will get any message that was sent while you were offline, but you can’t see the conversation you had earlier.

Example 2

You talk to someone from your computer at work, then you go home without quitting your work client and connect with your own computer. You won’t get any backlog at all.

The ugly solution

Instead of connecting all your clients to your ZNC user, you create an additional ZNC user for every client, so you have your main user plus one for each client. You then connect all additional ZNC users to the main user and all IRC clients to their respective ZNC user.

Say your name is John Doe, and you have three clients: xchat, irssi and mIRC. The connection diagram would look like this:

           _________________________________________________
          /                                                 \
         |                        ZNC                        |
         |                               via 127.0.0.1       |
xchat ------> user "johndoe_xchat"----------\                |
         |                                   v               |
irssi ------> user "johndoe_irssi"---> user "johndoe_main" ---> IRC
         |                                   ^               |
mIRC -------> user "johndoe_mIRC"-----------/                |
         |                                                   |
          \_________________________________________________/

This illustration was taken from the ZNC wiki.

Setting up the accounts like this will make each ‘client user’ store its own backlog. You can also configure the number of lines (the ‘buffer size’) per client, even on a per-channel basis, which might be useful if one of your clients is running on a smartphone. The disadvantage of this method is obvious – you need to set up multiple users. It’s kind of a hack to achieve the desired outcome.

The new solution

As of znc 1.6, clients can have a client identifier and there is a module called clientbuffer that makes use of it. With client identifiers, ZNC becomes aware which client you are using to connect to it, hence it can distinguish between your clients, and said module keeps a separate playback buffer for each client.

To see how to use it, you should read the wiki page. Basically, after installing and loading the module, you need to add identifiers to your clients by putting them in the password field:

username@identifier/network:password

or in the username field:

username@identifier/network

Then you need to make the module aware of the clients you want to use it with by issuing the AddClient command:

/msg *clientbuffer AddClient <identifier>

You also need to disable the Auto Clear Chan Buffer and Auto Clear Query Buffer options, otherwise ZNC will clear the buffers as soon as any client connects.

This feels like the ‘right’ way to do it, but it has some disadvantages as well: You can’t specify individual buffer sizes and – at least in my experience – it sometimes fails to clear the last message of a query so it is being sent again and again every time you connect (see this issue). This is somewhat annoying, but I chose to live with it rather than going the multi-user way or having only partial logs on all clients. There is now a patch that fixes this bug, so now the clientbuffer module is really the best option. Get the module from here.

Final words

As you can see, none of the three possible ways are perfect, but now you know what options you have available. I hope someone will add a per-client buffer size setting and fix the query bug some day – it would make the plugin pretty much perfect and even ready to be made an internal module in my opinion.

9 Comments

  1. i have clientbuffer module running and have set identifiers for both my desktop and mobile clients. when i use ListClients it is aware of which client is connected but i get no playback at all for either on znc 1.6.5. autoclearchanbuffer and autoclearquerybuffer are disabled and buffer limit is set to at least 50 lines on both clients… not sure what i’m doing wrong and i can’t find any info online. has anyone else ran into a problem like this??

  2. This works like a charm, thank you! Have been playing with it a bit but can’t seem to go around the one particular issue on ZNC 1.6.5 version where, if any of the clients reconnects I get spammed with very long list of banned users into whatever channel I am in at the moment.

    To be clear, this only displays to me and looks somewhat like:

    ‎[00:40] ‎[BanList:#XYZchannel]‎ $a:XYZuser set by XYZmoderator on 6/25/17 5:16 AM

    Any ideas on how to resolve this?

  3. 1.7 w/ “Multiple Clients” selected. Disable auto clearing of buffers. Be sure to identify with a client identifier; e.g. nick@identifier/network:password.

  4. Great guide, thanks.

    I would add an additional note: You must repeat the “AddClient” step for every individual server you connect to. In my case, with two clients I chose to name “phone” and “laptop”, I wrote out something like this into a textfile…

    /msg *clientbuffer AddClient phone
    /msg *clientbuffer AddClient laptop
    /msg *clientbuffer ListClients

    …and then pasted it into each of my seven IRC server connections. After that, everything worked great. (*Before* that, all but one of my server connections would periodically re-post already-seen messages to every channel, and I had no idea why…)

  5. hmm Ive got it working via the ugly setup which connects laptop znc to main znc via 127 etc however I still get no playback for individual clients.

Leave a Reply to pascalpoitras Cancel reply

Your email address will not be published. Required fields are marked *