Menu

Possible to install an XMPP server?

VoIPuser
2014-03-09
2014-03-11
  • VoIPuser

    VoIPuser - 2014-03-09

    I would like to have the ability to send notifications to other computers on my local network when certain events occur. Since these other computers are running OS X, it would be ideal if I could find a way to push Bonjour IM's to other machines, but I doubt there's a way to do that under Linux. But since iChat also supports XMPP (Jabber) connections, I could send XMPP messages using Asterisk's built in XMPP capability. While I could use Gtalk (Google's IM service) for the purpose I'd rather keep my messages on my own local network and not be dependent on their servers.

    I came across a page on Setting up Prosody on the Raspberry Pi, which seems to indicate that I could set up a XMPP server right alongside RasPBX. I can't see any reason this wouldn't work, since it appears to be a simple apt-get install, but just thought I'd ask first if you know of any reason I should not do this, or perhaps if you know of a better option for setting up an XMPP server, or maybe a way to actually send Bonjour IM's to OS X machines.

    I'm assuming that RasPBX does not come with an XMPP server already built in, correct?

    (EDIT: Original link no longer works, so edited to show cached page in the Wayback Machine).

     

    Last edit: VoIPuser 2017-01-27
  • VoIPuser

    VoIPuser - 2014-03-10

    Just to clarify, the question I am really asking is this. From the page linked above:

    As stable Prosody, currently 8.2, is in the raspbian repos you install it via apt.

    sudo apt-get install prosody

    which will install (if they are not already installed)

    liblua5.1-0 lua-event lua-expat lua-filesystem lua-sec lua-socket prosody
    ssl-cert

    To the best of your knowledge, will installing any of those in any way interfere with the operation of RasPBX, or slow down the Raspberry Pi to the point that it would interfere with calls? Basically I'd just like a heads up if I'm about to do something stupid by installing this.

     
  • dziny

    dziny - 2014-03-10

    I don't see why this would not work, but if you are unsure just do a backup of your SD card (either just dd or if you want to save space you can also use fsarchiver). That way you can always restore your working config if something goes wrong for you.

     
  • Gernot

    Gernot - 2014-03-10

    There is no XMPP server installed by default on RasPBX. Therefore I would just give it a try, I can't see a reason why this should not work.

     
  • VoIPuser

    VoIPuser - 2014-03-11

    I went ahead and tried it. I started out by doing

    sudo apt-get install prosody
    

    Which installed fine but at the end it said:

    [....] Starting Prosody XMPP Server: prosody
    **************************
    Prosody was unable to find LuaSec
    This package can be obtained in the following ways:
    
        Source:           http://www.inf.puc-rio.br/~brunoos/luasec/
        Debian/Ubuntu:    http://prosody.im/download/start#debian_and_ubuntu
        luarocks:         luarocks install luasec
    
    SSL/TLS support will not be available
    More help can be found on our website, at http://prosody.im/doc/depends
    

    So I then did

    sudo apt-get install lua5.1-sec
    

    (that package had been "recommended" during the initial install). It actually installed lua-sec, and that did silence the complaint at the end of Prosody startup, but I didn't think that SSL was actually working because I never was able to check the "Use SSL" box in my chat client and get it to work; it would fail to connect every time. Which at the time really wasn't a big deal for what I was trying to do. I probably spent a couple hours trying to make it work anyway, created the certificates and so on, but in the end I didn't think it was working and since I didn't need it, I wasn't going to spend any more time on it. HOWEVER it turns out that I probably had it working and just didn't realize it, because checking the "Use SSL" box in my chat client was the wrong thing to do - see the "Making SSL work" section at the bottom of this post.

    There are basically three main things you have to do after you install - add users, modify the /etc/prosody/prosody.cfg.lua file, and (optionally) set up your /etc/asterisk/xmpp_custom.conf file.

    To add users you run the command:

    sudo prosodyctl adduser Asterisk@yourraspbxserver.com
    

    Replace Asterisk with the desired user name (but you should create one for Asterisk if you want it to be able to send messages, though you can give it any name you want). yourraspbxserver.com should be replaced with your static or dynamic address, or if you don't have one, the local dotted ip address of the server. Do this for each user (IM client) that will be logging in.

    In /etc/prosody/prosody.cfg.lua I made these changes. Note that I did not intend to allow access from outside the local network:

    Added myself to the "admins" line (note you can add multiple users as admins, but they all must be added using sudo prosodyctl adduser, it is NOT sufficient to just add them here):

    admins = { "you@yourraspbxserver.com" }
    

    Commented out BOTH ssl sections so the server wouldn't throw error messages (note that two hyphens indicates a comment):

    -- ssl = {
    --  key = "/etc/prosody/certs/localhost.key";
    --  certificate = "/etc/prosody/certs/localhost.cert";
    -- }
    

    And further down, near the bottom of the file:

             -- ssl = {
             --         key = "/etc/prosody/certs/example.com.key";
             --         certificate = "/etc/prosody/certs/example.com.crt";
             -- }
    

    (Note that if you try to get SSL to work, I'm told that if you only have one Virtual Host you should set the paths in the first section, but you could leave the second commented out if you like. Or, you could set the same paths in both places. Once I realized that I could get SSL to work, I uncommented both sections and changed both to point to the key and cert files I had generated. See the "Making SSL work" section at the bottom of this post).

    I also commented out the "info" logging line once I had everything working - I actually left this enabled while debugging but once everything is working I don't need all those extra writes to the SD card:

        -- info = "/var/log/prosody/prosody.log";
    

    The last thing was changing the VirtualHost line and enabling it:

    VirtualHost "yourraspbxserver.com"
        enabled = true -- Remove this line to enable this host
    

    (I changed that last line from "false" to "true" rather than removing it).

    After making those changes and saving the modified file I had to run this to restart the server:

    sudo /etc/init.d/prosody restart
    

    Note that whenever you run that it will drop all your connections from any clients you have running.

    Now I was able to get my clients to connect, I had to specify the account name in the form you@yourraspbxserver.com, and then in the server settings specify the ip address of the Raspberry Pi.

    As for Asterisk, this is what I used in the /etc/asterisk/xmpp_custom.conf file:

    [general]
    ;debug=yes              ;;Turn on debugging by default.
    ;autoprune=yes              ;;Auto remove users from buddy list. Depending on your
                        ;;setup (ie, using your personal Gtalk account for a test)
                        ;;you might lose your contacts list. Default is 'no'.
    autoregister=yes            ;;Auto register users from buddy list.
    
    [asterisk]              ;;label
    type=client                             ;;Client or Component connection
    serverhost=127.0.0.1                    ;;Route to server for example,
                                            ;;      talk.google.com
    username=Asterisk@yourraspbxserver.com  ;;Username with optional resource.
    secret=password_in_prosody              ;;Password
    priority=1                              ;;Resource priority
    port=5222                               ;;Port to use defaults to 5222
    usetls=no                               ;;Use tls or not
    usesasl=yes                             ;;Use sasl or not
    buddy=you@yourraspbxserver.com          ;;Manual addition of buddy to list.
    buddy=anotheruser@yourraspbxserver.com
    status=available                        ;;One of: chat, available, away,
                                            ;;      xaway, or dnd
    statusmessage="No real-time chat"       ;;Have custom status message for
                                            ;;Asterisk.
    timeout=100                             ;;Timeout on the message stack.
    

    Note the "buddy" lines, you should have one for each user that will receive messages from Asterisk. To send a message from some custom dialplan you have created (such as in extension_custom.conf) you use the JabberSend command (they haven't yet updated the commands to use XMPP rather than Jabber, apparently). So you might have something like:

    exten => 1234,n,JabberSend(asterisk,user@yourraspbxserver.com,Call from ${CALLERID(name)} at ${CALLERID(num)} for extension 1234 received ${STRFTIME(${EPOCH},,%l:%M:%S %p on %A %B %e)})
    

    To send a notification of an incoming call, IF you were running plain vanilla Asterisk. In FreePBX it is a bit trickier to add something like this because you have to figure out how to get such a line into the dialplan, and there aren't any particularly elegant ways to do it that I am aware of (I can post a really ugly way if someone wants it).

    I have no idea if I did this the best way. I was switching between about three different "how to" pages, each of which seemed to have its own ideas about the best way to configure this thing. All I know is that the above worked for me, except for thinking that I could not get SSL to work, and that wasn't important to me because I'm not allowing connections from outside my local network. If anyone else sees a better way to set this up, I won't feel offended if you post how you did it.

    Making SSL work

    After a chat in the Prosody Chat Room I realized that I probably did in fact have SSL working, but didn't think it was working because whenever I checked the "Use SSL" box in my chat client, it would not work. But I am told that checkbox simply tells the IM client to use what some people call "legacy SSL", which uses port 5223 and is disabled by default in Prosody. If you uncheck the box, it uses SSL on port 5222, which is now the standard way, but of course that assumes you haven't gone in and disabled encryption at the server because you thought it wasn't working! :(

    What you apparently need to do to get encryption to work is install the certificates (which can be self-signed) and then tell Prosody where they are, by uncommenting and editing the two ssl sections in /etc/prosody/prosody.cfg.lua mentioned above. While your certificate files could be stored anywhere on your system, you may want to put them in the /etc/prosody/certs directory, which should have been created when you installed Prosody. I suppose that alternately you could put them in /etc/ssl/certs, but I see no advantage to doing that.

    Here is a command you can run from the Linux command prompt to create the certificate files and put them in the /etc/prosody/certs directory:

    sudo openssl req -new -x509 -days 365 -nodes -out "/etc/prosody/certs/yourraspbxserver.com.crt" -newkey rsa:2048 -keyout "/etc/prosody/certs/yourraspbxserver.com.key"
    

    yourraspbxserver.com should be replaced at both places where it appears, in the same way you replaced it when configuring /etc/prosody/prosody.cfg.lua and /etc/asterisk/xmpp_custom.conf

     

    Last edit: VoIPuser 2014-03-17

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.