REST Apps service not running?

On a new and clean installation of FreePBX from the prebuilt image (64 bit) I’ve purchased and installed the EPM and RestApps. I’ve used endpoint manager to add an XML button for Apps, which the phone’s web admin shows as being linked to:

http://10.10.0.111:88/applications.php/restapps/main?user=401

The internal IP is the FreePBX instance, dont know about the port 88. That link goes nowhere, no server seems to be running. Pressing the button gives “Connect Timeout” on the phone screen.

I’ve been reading the Wiki which mentions setting up user tokens, but neglects to state how this should be done, but I doubt that’s relevant as the Rest service seems not to be running. And yes, Settings|Advanced Settings|Enable the Asterisk REST Interface is set to True

How should I go about working this out? Thanks.

That port is pulled from sysadmin port management. Go submit that page to make sure it writes out the correct configuration.

As far as Token setup this is handled in User Management in FreePBX under each user.

In the wiki here step one has a link telling you to verify Users are setup with Rest API enabled. http://wiki.freepbx.org/display/FCM/RESTful+Phone+Apps-Adding+a+RESTful+Application+to+a+device

Thanks Tony,
I’ve checked the port (and then changed it to something else, submitted, changed it back, submitted again and then rebooted, just to be sure)
I’m getting no response from the service at all, the phone shows a message of “cannot display” and a web browser gives “failed to open page” so while I think I’ve got the user set up right, I don’t think it matters at this stage as it does not seem to be getting that far.

the result of
/etc/init.d/restapps status
is
restapps.php (pid 2147) is running…

but
wget localhost:88
on the PBX server gives
Resolving localhost… ::1, 127.0.0.1
Connecting to localhost|::1|:88… failed: Connection refused.
Connecting to localhost|127.0.0.1|:88… failed: Connection refused.

so I’m not convinced it’s truly running.

Again, this is using the FreePBXDistro STABLE – 6.12.65 and Asterisk 13 has been selected. Other than the commercial modules, and a few extensions, nothing else has been installed.

Hope there’s an answer out there somewhere! Thanks.

Is incrond running.

Try a

service incrond status

and paste the output

service incrond status
incrond (pid  1813) is running...

:frowning:

The service that’s listening on port 88 is apache. It appears that your apache configuration isn’t correct. Are you sure that you have restapps listening on port 88? You need to check that in System Admin.

You can have a look at what Apache thinks in /etc/httpd/conf.d/schmoozecom.conf

Sure, here’s Admin | System Admin | Ports

However, the apache pointer gave good results, here’s the file, there’s nothing listening on port 88 or 96 as in the gut, instead it shows restapi on 85 and restapps on 84:

cat schmoozecom.conf 
# Automatically Generated File - 1438002210
# {"acp":{"port":"80","dir":"\/var\/www\/html"},"ucp":{"port":"81","dir":"\/var\/www\/html\/ucp\/"},"restapi":{"port":"85","dir":"\/var\/www\/html\/restapi\/"},"restapps":{"port":"84","dir":"\/var\/www\/html\/restapps\/"},"hpro":{"port":"83","dir":"\/tftpboot\/"},"xml":{"port":"82","dir":"\/var\/www\/html\/aastra\/"}}
# acp
Listen 80
<VirtualHost *:80>
    DocumentRoot /var/www/html
</VirtualHost>
# ucp
Listen 81
<VirtualHost *:81>
    DocumentRoot /var/www/html/ucp/
</VirtualHost>
# restapi
Listen 85
<VirtualHost *:85>
    DocumentRoot /var/www/html/restapi/
</VirtualHost>
# restapps
Listen 84
<VirtualHost *:84>
    DocumentRoot /var/www/html/restapps/
</VirtualHost>
# hpro
Listen 83
<VirtualHost *:83>
    DocumentRoot /tftpboot/
</VirtualHost>

Calling the original URI in a browser, but with port 84 gives a solid result:

{"application_name":"restapps","application_display":"Applications","page_name":"main","type":"display","exitPath":null,"layout":[{"type":"link","name":"findmefollow-main","display":"Follow Me","value":"findmefollow\/main"},{"type":"link","name":"voicemail-main","display":"Voicemail","value":"voicemail\/main"},{"type":"link","name":"voicemail-transfer","display":"Transfer VM","value":"voicemail\/transfer"},{"type":"link","name":"endpoint-main","display":"Endpoint Manager","value":"endpoint\/main"},{"type":"link","name":"callforward-main","display":"Call Forward","value":"callforward\/main"},{"type":"link","name":"conferences-main","display":"Conference","value":"conferences\/main"},{"type":"link","name":"parking-main","display":"Parking","value":"parking\/main"},{"type":"link","name":"queues-main","display":"Queues","value":"queues\/main"},{"type":"link","name":"queues-agent","display":"Queue Agent","value":"queues\/agent"},{"type":"link","name":"daynight-main","display":"Call Flow","value":"daynight\/main"},{"type":"link","name":"timeconditions-main","display":"Time Conditions","value":"timeconditions\/main"},{"type":"link","name":"donotdisturb-main","display":"DND","value":"donotdisturb\/main"},{"type":"link","name":"contactmanager-main","display":"Contacts","value":"contactmanager\/main"},{"type":"link","name":"presencestate-main","display":"Presence","value":"presencestate\/main"}],"action":[],"error":[]}

So, over to the phone web admin to directly edit the settings, and I get a better response from the softbutton, in that the ‘apps’ one (http://10.10.0.111:84/applications.php/restapps/main?user=403) shows a menu of apps, but selecting those, or pressing the other buttons gives the “Cannot display” message again.

http://10.10.0.111:84/applications.php/contactmanager/main?user=403 for example, returns this in a browser:

{"application_name":"contactmanager","application_display":"Contacts","page_name":"main","type":"display","exitPath":null,"layout":[],"action":[],"error":[{"reason":0}]}

Over to Admin | User Management.
There’s a user there with a login of 403, RestAPI is enabled for it, a token and token key are shown, Modules is set to All

So, back to the wiki, which does indeed say “Verify User has RESTful API Setup” but does little to explain it. Tokens are mentioned, but what’s the difference between a token and token key, for example?

So. Getting closer. No idea why the apache config is wrong but I’ll look into it, could it possibly be a bug?
Any further help on getting these XLM apps to work would be greatly appreciated.
Thanks.

UPDATE:
I used the GUI to change (again) the restapps port to 89, submitted it and checked the schmooze.conf file; it had changed. Set it back to 88 and checked again, changed to 88. Rebooted server, checked file, still on 88. shrug

Ok, so now we get some sensible errors: “User Manager is not enabled for 403-1” when I try "Contacts"
a browser gives:

{"application_name":"contactmanager","application_display":"Contacts","page_name":"main","type":"display","exitPath":null,"layout":[{"type":"entry","display":"No groups configured for user 403"}],"action":[],"error":[]}

The 403-1 part caught my eye. There are two sip servers configured for the device, using EPM for account1 and account2. The main asterisk server is the account1. So Into user manager to edit the login name from 403 to 403-1. It made no difference, sadly.

The second part is the “no groups” message, well 403 is part of a ring group, but I doubt that’s anything related.
It’s really only the contacts app that I need, assuming it does what I think it does, it’ll show the usernames and xtn number for the extensions configured on the switch, right? and obviously allow selection and dialling of them.

Are you using pjsip? I dont get the 403-1. Extensions have to be numeric only in FreePBX.

yup, the extensions are configured with pjsip, I didn’t set the suffix, it did, and it’s not seen in the URL or the JSON return, but it did show on the phone screen as that error.

Should I convert them over to plain chansip ?

Ya pjsip is still experimental with FreePBX 12 and we are trying to address this in FreePBX 13 which is still Beta.

1 Like

Can you open a bug report so we can get this fixed at issues.freepbx.org

1 Like

AH, didn’t know it was experimental.
Ok, before I file the bug, I’ve checked this:

Changed xtn403 to chanson, applied changes.
Deleted 403 and 401-1 from Endpoint Manager
Rescanned network re-added device as 403
Didn’t add the second SIP server this time
Reset phone to factory defaults and rebooted
Once settings had been applied, press the ‘Contacts’ soft button…
phone displays “no groups configured for 403”

so still got the same problem, really.

I then pressed (in EPM) ‘Add Extension’, picked custom, and provided it with the IP address of the other server, the same 403 extension and the SIP password and port. This time to second line was not created with the -1 suffix. So the bug is reproducible, if it’s a bug. I’ll log accordingly.

[To clarify here, what I’m trying to do is run Asterisk in parallel with an existing PBX, so each endpoint needs to be connected by SIP to both, and configured in a similar way (hence, same extension number) which will allow for a transition away from the old PBX.]

I tried a few other options from the RestAPP ‘Apps’ soft button and noticed that while most give ‘cannot display’ and the contacts one complains about a group. the one for ‘Follow me’ does give a valid response and shows options for ring time etc.

So, looks like a possible bug with EPM & pjsip, and something of a ‘how to use’ with the Contacts RestAPP?