Enketo-express working with ODK Aggregate, but not with Formhub. What am I doing wrong?

339 views
Skip to first unread message

El Piqo

unread,
Feb 24, 2015, 10:53:43 AM2/24/15
to enketo...@googlegroups.com
Hi there, 

I've made Formhub work with enketo-express before, but now I'm trying with a newer version of Enketo-express (my version was about 1-2 months old) and I am having issues. I might be missing something obvious. 

It works perfectly with ODK Aggregate (even for protected forms), but when I try from Formhub it fails: it shows Request to http://MY_FORMHUB_URL/fhuser/formList failed.
Below at the console I see,  Failed to load resource: the server responded with a status of 405 (Method Not Allowed)  http://my_enketo_url:13131/transform/xform



Configuration & Logs

My Formhub settings (preset/default_settings.py):
ENKETO_PREVIEW_URL = ENKETO_URL + 'preview'
ENKETO_API_INSTANCE_IFRAME_URL = ENKETO_URL + "/api/v2"
ENKETO_API_TOKEN = 'MY_API' # use your Enketo API key here


Grunt develop output when I request the form.
survey-model object retrieved from database for id "YYYP" +24s { openRosaServer: 'http://MY_FORMHUB_URL/fhuser',
  openRosaId: 'AA',
  submissions: '0',
  launchDate: '2015-02-24T09:37:19.257Z',
  active: 'true',
  theme: '',
  lastAccessed: '2015-02-24T15:41:08.439Z' }
  openrosa-communicator sending request to url: http://MY_FORMHUB_URL/fhuser/formList +2ms


Config.json portion
    "port": "13131",
    "offline enabled": false,
    "linked form and data server": {
        "name": "KoBoCAT",
        "server url": "*",
        "api key": "MY_API",
        "authentication": {
            "managed by enketo": true,
            "allow insecure transport": true,
            "external login url that sets cookie": "http://example.com/login?return={RETURNURL}"
        }
    },

I set server_url as * so I can accept requests from both ODK and formhub; I played around a lot with many of the settings but nothing so far. 

ps. when I visit http://MY_FORMHUB_URL/fhuser/formList using a browser I see the xml file of my uploaded forms.

Best, 
piqo

Martijn van de Rijdt

unread,
Feb 24, 2015, 11:36:33 AM2/24/15
to El Piqo, enketo...@googlegroups.com
Hi Piqo,

server url should be '' if you're linking to multiple servers.

Is http://MY_FORMHUB_URL/fhuser/formList available when you visit the page in your browser? Or is it only available on https perhaps?



--
You received this message because you are subscribed to the Google Groups "enketo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to enketo-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Revolutionizing data collection since 2012.

Enketo    |    LinkedIn    |    GitHub    |    Twitter    |    Blog

Martijn van de Rijdt

unread,
Feb 24, 2015, 3:25:34 PM2/24/15
to enketo...@googlegroups.com, Edi Piqoni
Yes, the latest version should work with protected forms on Aggregate, Formhub, Ona, KoBo etc since version 1.7.0.

Maybe try to log the response from the request to http://MY_FORMHUB_URL/fhuser/formList on the server, e.g. just before this line (this link is temporary - in the future it will likely point somewhere else), add: debug('reponse', error, response.statusCode);

On Tue, Feb 24, 2015 at 1:13 PM, Edi Piqoni <piq...@gmail.com> wrote:
Hi Martijn, 
yes, formList endpoint shows fine even in 'http'. Its not caused neither by the server url, because I had left it empty initially. 
Perhaps it has to do with the protected form in Formhub? 
From what I have read in Enketo's website, Formhub is an OpenRosa compliant so theoretically it must work with protected forms in Formhub as well, right? 

Best, 
Piqo


Edi Piqoni

unread,
Feb 24, 2015, 4:02:49 PM2/24/15
to Martijn van de Rijdt, enketo...@googlegroups.com
To me, that is great news (that will work with Formhub). 

Error Logs: 

{code: 405, message: "Request to http://my_formhub_url/fhuser/formList failed.", stack: "Error: Request to http://my_formhub_url/fhuser/fo…:16↵    at process._tickCallback (node.js:419:13)", status: 405}

Stack:
"Error: Request to http://my_fomhub_url/fhuser/formList failed.
    at Request._callback (/home/orbeon/enketo-express/app/lib/communicator/communicator.js:229:21)
    at Request.self.callback (/home/my_dir/enketo-express/node_modules/request/request.js:344:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/home/my_dir/enketo-express/node_modules/request/request.js:1239:14)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/my_dir/enketo-express/node_modules/request/request.js:1187:12)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickCallback (node.js:419:13)"


Martijn van de Rijdt

unread,
Feb 24, 2015, 4:39:29 PM2/24/15
to Edi Piqoni, enketo...@googlegroups.com
Thanks,

I was able to reproduce it with formhub.org. It seems there is a subtle difference with Ona (I had only tested with Ona and ODK Aggregate). You can track the bug here: https://github.com/kobotoolbox/enketo-express/issues/165

It does not appear to be related to authentication.

Cheers,
Martijn

Martijn van de Rijdt

unread,
Feb 24, 2015, 5:11:26 PM2/24/15
to Edi Piqoni, enketo...@googlegroups.com
I created a fix that works for me. Can you check as well? Thanks!

El Piqo

unread,
Feb 24, 2015, 5:28:23 PM2/24/15
to enketo...@googlegroups.com, piq...@gmail.com
Ok, I changed that line to return _request( options )
and now the form shows, but authentication doesnt seem to work. The form is set private,,, but publicly available. 

(I will have to check tomorrow, and confirm) 

Thanks

El Piqo

unread,
Feb 25, 2015, 11:34:51 AM2/25/15
to enketo...@googlegroups.com, piq...@gmail.com
Found why the form was public, looked into formhub code and found that UserProfile model had a require_auth field that should have been true. (its a setting in user settings)

Now it works sometimes [about half of the time] because of a formhub-related error when openrosa-communicator sends the request to url: http://my.formhub.url/fhuser/formList +10ms . I'll contact formhub guys [if the project is still active, last commit about 6 months ago], but I'm also posting the error here, just in case, some other enketo-user faces the same problem:

DatabaseError at /fhuser/formList

DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 139787581331200 and this is thread id 139787525252864.
Request Method:GET
Request URL:http://my.formhub.url/fhuser/formList
Django Version:1.5.10
Exception Type:DatabaseError
Exception Value:
DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 139787581331200 and this is thread id 139787525252864.
Exception Location:/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py in validate_thread_sharing, line 154
Python Executable:/usr/local/bin/uwsgi
Python Version:2.7.3
Python Path:
['.',
 '',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PIL']
Server time:Wed, 25 Feb 2015 11:25:28 -0500

Best, 
piqo

Martijn van de Rijdt

unread,
Feb 25, 2015, 11:41:40 AM2/25/15
to El Piqo, enketo...@googlegroups.com
Thanks piqo,

That's very useful.

I'm afraid you won't get a response from formhub until the project is revived. I'd recommend looking into two active forks instead: Ona and KoBo.

Cheers,
Reply all
Reply to author
Forward
0 new messages