Producing Content-Length 0 Responses in Rails

Was this helpful? Share it!

    Returning a blank response in Ruby on Rails is trickier than we first imagined. For instance, we thought that either one of these two methods would suffice:

    render text: nil
    render nothing: true

    But they don’t. Both of these methods result in a response with a Content-Length value of 1. What’s the content? A single hex character of 20, which represents a single whitespace character.

    We played around with a few other options and found that this is the most straightforward method to provide a truly blank response:

    render text: ''
    Was this helpful? Share it!

      Configuring a Cisco 9951 Phone for Asterisk

      Was this helpful? Share it!

        Keep in Mind

        The Cisco Unified IP Phone 8961, 9951, and 9971 phones were not designed to work with any phone system other than Cisco Unified Communications Manager. So, this effort is essentially a hack. If you are OK with certain features not working, like the Contacts button or aspects of Voicemail indication/calling, proceed. If you are looking for tight integration between your endpoints and your Asterisk PBX, you’ll want to consider a phone that supports Asterisk, such as a Polycom, Snom, Grandstream, Aastera, or Linksys device.

        What are the Tricky Parts?

        Cisco phones have never been terribly straightforward to configure. The 9951 introduces a few more curveballs, which I will mention here. Other peculiar aspects, which the 9951 shares with the previous 79XX series of phones have been left out as there are ample resources available elsewhere.

        The 9951 brought these additional challenges:

        • SIP over TCP support only (no traditional SIP over UDP allowed)
        • A particular bug that can cause troubleshooting confusion
        • Seemingly different XML configuration requirements

        Configuring Asterisk for SIP over TCP

        We are using Asterisk 1.8, so adding TCP support is simply a matter of configuration. I believe this is a similar case for 1.6. If you are using Asterisk 1.4, you will need to determine how to add TCP support as it is not native.

        There are two steps to configuring SIP over TCP. The first is to enable it at the global level in Asterisk. Add the following to your SIP configuration. If you’re using vanilla Asterisk, you can put this in your sip.conf file below [general]. If you’re using FreePBX, the most appropriate place is in sip_general_custom.conf.


        Next, make sure that transport=tcp for each extension that you plan to use the 9951 with.

        Once you’ve completed these steps, open the Asterisk CLI and run sip reload to apply the settings.

        Self Call Bug

        We found that calling ourselves from the 9951 and then answering the call resulted in the phone keeping a “dead” call open on the screen. This seems like nothing more than a visual artifact, but it actually causes loss of additional functionality on the phone. During our troubleshooting, we’d SSH into the device and issue reset soft commands to force the device to grab it’s new configuration. Once we had one of these dead calls, reset soft would no longer do anything, adding to our confusion as we tried to get the phone up and running. Beware!

        XML Configuration Files

        Yes, the part that most of you have been waiting for. Here is the configuration that ended up working for us. You will want to modify this configuration and save it to a file named SEP[MAC_ADDRESS].cnf.xml on your TFTP server. Replace all of the bracketed sections with your applicable settings.

        Note: Make sure that the proxy node under the sipLines/line node remains set to USECALLMANAGER. We were unable to get the device to register with Asterisk when we individually added the hostname or IP of our PBX here.

                 <timeZone>Pacific Standard/Daylight Time</timeZone> 
                    <member priority="0"> 
                          <processNodeName>[YOUR PBX HOST/IP]</processNodeName> 
              <phoneLabel>[LABEL THAT APPEARS AT TOP OF SCREEN]</phoneLabel> 
                 <line button="1"> 
                    <featureLabel>[LINE LABEL ON SCREEN]</featureLabel> 
                    <name>[SIP EXTENSION]</name> 
                    <displayName>[SIP EXTENSION]</displayName> 
                    <authName>[SIP EXTENSION]</authName> 
                    <authPassword>[SIP PASSWORD]</authPassword> 
                    <contact>[SIP EXTENSION]</contact> 

        We also found that the dialplan.xml file is respected as it was with previous Cisco phones. Ours looks like this, though yours may vary:

        	<TEMPLATE MATCH="91.........." Timeout="0"/>
        	<TEMPLATE MATCH="911" Timeout="0"/>
        	<TEMPLATE MATCH="\*.." Timeout="0"/>
        	<TEMPLATE MATCH="[1-8].." Timeout="1"/>
        	<TEMPLATE MATCH="*" Timeout="5"/>


        The Cisco 9951 has a Messages button on the front that presumably integrates with a Cisco Communications Manager to provide some form of visual voicemail. We have yet to find a way to reprogram this button to integrate with Asterisk.

        As a workaround, we’ve created a speed dial button that does connect directly to Asterisk Voicemail. We added this config to our SEP[MAC_ADDRESS].cnf.xml file:

        <line button="2">

        Outstanding Issues

        We’d still like to find answers to the following:

        • How can we wire the Messages button to automatically dial *97 (Asterisk Voicemail)?
        • Can we configure the Contacts button to show contacts populated by an XML file? Setting DirectoryURL didn’t seem to do anything.

        Control Apple Devices and Apps

        SimpleMDM allows you to configure, secure, and track iPads, iPhones, and OS X remotely, via the web. SimpleMDM provides advanced functionality usually exclusive to convoluted enterprise offerings.

        Was this helpful? Share it!