"HTTP/1.1 411 Length Required" when trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms module)
http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guidewe
have two possible URLs to use:
http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=passwordhttp://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

··· * * http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our tomcat's
log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log here, so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending request:
POST /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx
HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx
HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding: chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=
xxxxxxxx HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding: chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition: form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.family_name openmrs_table="patient_name"
openmrs_attribute="family_name" /><patient.given_name
openmrs_table="patient_name" openmrs_attribute="given_name"
/><patient.patient_id openmrs_table="patient" openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">1</encounter.provider_id><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"

2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server: nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010 01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type: text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length: 181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving
response: HTTP/1.1 411 Length Required

2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec 2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type: text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload to
server at
http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxxhttp://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=dairai8Gfailed.
Will try again in 60000 ms.

--
Pavel Stephan Muñoz

One thing that looks fishy is that you're sending URL encoded parameters
(uname=name&pw=password) in a multipart-encoded form. If you want to send
parameters in a multipart post, try adding them to the message body.

Not sure if this is the problem, but it seems like a likely culprit :slight_smile:

Adam

··· On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz wrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)
http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guidewe have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=passwordhttp://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password
*
*
http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log here, so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request: POST /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx
HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx
HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=
xxxxxxxx HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding: chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition: form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.family_name openmrs_table="patient_name"
openmrs_attribute="family_name" /><patient.given_name
openmrs_table="patient_name" openmrs_attribute="given_name"
/><patient.patient_id openmrs_table="patient" openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">1</encounter.provider_id><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"

2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server: nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010 01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type: text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length: 181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving
response: HTTP/1.1 411 Length Required

2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec 2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type: text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload to
server at
http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxxhttp://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=dairai8Gfailed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

Hi all,

ODK along with other OpenROSA submissions transports in chunked
encoding as part of the header, as per the HTTP 1.1 spec.

From what I gather, Nginx out of the box does not support or honor the
chunked encoding header and fails hard when a content-length header is
not present in an HTTP POST as ODK submits. The 411 error is the
telltale sign of this error.

I personally ran into this and tried to remedy by using a later
version of nginx (> 0.8.35)
*) Feature: the "chunked_transfer_encoding" directive.

However, I could not get it to work. I even tried a few workarounds
with different combination of proxy buffering and the like.

The remedy I've seen online but haven't tried personally is to use the
Chunkin Module which requires rebuilding nginx from source:

http://wiki.nginx.org/HttpChunkinModule

Ultimately, this was an issue we had to work around. The current
workaround we use is having all submissions go through apache2 with
mod_proxy. We proxy all posts from port 80 (or 443) on submission, to
a separate internal port (port 81), but add the mod_proxy
environmental variable SetEnv SendCL 1
(see http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http)

Assuming you can get the POST working with nginx, there is potentially
another problem to contend with. On the return 201 message, that too
may cause a 411 error if there is any body in the 201 response. You
may also need to explicitly set a content length on the response even
it if it is zero or non zero.

Hope this helps,
Dan

··· On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz wrote: > Hello masters ;), > > I have set ODKVoice to upload Xforms to our OpenMRS deployment after each > call is ended. I did so by editing the UPLOAD_URL string in the > constants/GlobalConstants class. According to this (from the xforms module) > http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide > we have two possible URLs to use: > http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password > http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password > > I have tried both options but we are getting a strange error in our tomcat's > log. It says: HTTP/1.1 411 Length Required[EOL]. > Sounds like ODKVoice is not creating proper HTTP headers for this > transaction; I mean "sounds like", but I doubt it. Other idea I have about > possible causes: our tomcat is behind a nginx web server... > > Can you bring us a light, as you always do? I am pasting the log here, so > you can check. > Thank you all. > > Pavel Stephan Muñoz. > ----------------------------- > > 2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending request: > POST > /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > HTTP/1.1 > 2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST > /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > HTTP/1.1[EOL]" > 2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding: chunked[EOL]" > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type: > multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]" > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]" > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]" > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]" > 2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST > /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > HTTP/1.1 > 2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding: chunked > 2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type: > multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf > 2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org > 2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive > 2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]" > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> > "--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]" > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition: form-data; > name="xml_submission_file"; filename="text/xml"[\r][\n]" > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type: > application/octet-stream[\r][\n]" > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding: > binary[\r][\n]" > 2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]" > 2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?> id="12" name="Llamada de Prueba" version="0.1" > xmlns:openmrs="formentry.infopath_server_url cannot be > empty/moduleServlet/formentry/forms/schema/12-1" > xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" > xmlns="http://www.w3.org/2002/xforms"> /> openmrs_table="patient_name" openmrs_attribute="family_name" > /> openmrs_attribute="given_name" /> openmrs_attribute="patient_id" > /> openmrs_table="encounter" openmrs_attribute="encounter_datetime" > /> openmrs_attribute="location_id">1 openmrs_table="encounter" > openmrs_attribute="provider_id">1 openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT" > openmrs_datatype="ZZ"> openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT" > openmrs_datatype="NM"> xmlns:n0="http://www.w3.org/2001/XMLSchema-instance" /> xmlns:n1="http://www.w3.org/2001/XMLSchema-instance" /> xmlns:n2="http://www.w3.org/2001/XMLSchema-instance">2 />" > 2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]" > 2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]" > 2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]" > 2010-12-28 22:27:02,357 DEBUG wire:64 - >> > "--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]" > 2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]" > 2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]" > 2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]" > 2010-12-28 22:27:02,358 DEBUG wire:78 - < Required[EOL]" > 2010-12-28 22:27:02,358 DEBUG wire:78 - < 2010-12-28 22:27:02,358 DEBUG wire:78 - < GMT[EOL]" > 2010-12-28 22:27:02,358 DEBUG wire:78 - < 2010-12-28 22:27:02,358 DEBUG wire:78 - < 2010-12-28 22:27:02,358 DEBUG wire:78 - < 2010-12-28 22:27:02,358 DEBUG wire:78 - < 2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving > response: HTTP/1.1 411 Length Required > 2010-12-28 22:27:02,359 DEBUG headers:232 - < 2010-12-28 22:27:02,359 DEBUG headers:235 - < 2010-12-28 22:27:02,359 DEBUG headers:235 - < 01:27:13 GMT > 2010-12-28 22:27:02,359 DEBUG headers:235 - < 2010-12-28 22:27:02,359 DEBUG headers:235 - < 2010-12-28 22:27:02,359 DEBUG headers:235 - < 2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 - > 'http.protocol.handle-redirects': false > 2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header was > absent > 2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload to > server at > http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > failed. Will try again in 60000 ms. > > -- > Pavel Stephan Muñoz > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en >

The url which should work for multipart-encoded forms like the ones from ODK
is the first one (without the ".form"):

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=passwordhttp://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

··· * * I tried to modify the documentation but was denied access (i think there were changes to user accounts). But feel free to modify the documentation.

From you logs:

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending request:
POST /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx
HTTP/1.1

Can you remove the ".form" and try again?

On Wed, Dec 29, 2010 at 10:28 AM, Adam Lerer adam.lerer@gmail.com wrote:

One thing that looks fishy is that you're sending URL encoded parameters
(uname=name&pw=password) in a multipart-encoded form. If you want to send
parameters in a multipart post, try adding them to the message body.

Not sure if this is the problem, but it seems like a likely culprit :slight_smile:

Adam

On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz minibota@gmail.comwrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)
http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guidewe have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=passwordhttp://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password
*
*
http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log here, so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request: POST /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx
HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx
HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=
xxxxxxxx HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding: chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition:
form-data; name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered
/><patient.family_name
openmrs_table="patient_name" openmrs_attribute="family_name"
/><patient.given_name openmrs_table="patient_name"
openmrs_attribute="given_name" /><patient.patient_id openmrs_table="patient"
openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">1</encounter.provider_id><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"

2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server: nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010
01:27:13 GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type: text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length: 181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving
response: HTTP/1.1 411 Length Required

2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length
Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec 2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type: text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload to
server at
http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxxhttp://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=dairai8Gfailed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

Hello everybody.

Thanks all for your kind support.
Daniel Myung was absolutely right, Nginx is not compatible with chunked
encoding. You can read here
http://www.lamnk.com/blog/computer/fix-nginx-411-length-required-error/ if
you are curious.

Anyway, we "bypassed" Nginx and sent data directly to Tomcat in this case.

After solving this issue I ran into 3 o 4 problems maybe, but that does not
matter anymore. Right now Xforms seem to be arriving to OpenMRS, better
said: they at least reach the
XformDataUploadManager.processXform(...)method from Xforms module, but
then I get the following in OpenMRS's log:

ERROR - XformsUtil.reportDataUploadError(615) |2011-01-08 04:13:16,249| null
java.lang.NullPointerException
at org.apache.commons.io.IOUtils.toInputStream(IOUtils.java:612)
at
org.openmrs.module.xforms.download.XformDataUploadManager.processXform(XformDataUploadManager.java:88)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doGet(XformDataUploadServlet.java:79)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doPost(XformDataUploadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

It refers to line 88 of XformDataUploadManager where we have:

    public static void processXform(String xml, String sessionId, String

enterer, boolean propagateErrors,HttpServletRequest request) throws
Exception{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc =
db.parse(IOUtils.toInputStream(xml,XformConstants.DEFAULT_CHARACTER_ENCODING));
setHeaderValues(doc,sessionId,enterer);

queueForm(XformsUtil.doc2String(doc),propagateErrors,request);
}

I have commons-io-1.4.jar, if that's useful to know.
This is shown in ODKVoice's log after a call is completed:

2011-01-08 04:13:16,209 INFO FormVxmlRenderer:317 - Set outbound status:
id=80; status=COMPLETE
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
2011-01-08 04:13:16,211 INFO FormVxmlRenderer:760 - Export data path:
/root/odkvoicedata/instances/+50588367336/1294470742015
2011-01-08 04:13:16,212 INFO FormVxmlRenderer:764 - XML path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
Path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
2011-01-08 04:13:16,213 INFO FormVxmlRenderer:784 - Queued
InstanceUploaderThread
2011-01-08 04:13:16,214 INFO FormVxmlRenderer:802 - About to upload
instance to
http://localhost:8080/openmrs_devel/moduleServlet/xforms/xformDataUpload?
uname=xxxxxx&pw=xxxxxx
2011-01-08 04:13:16,219 DEBUG SingleClientConnManager:195 - Get connection
for route HttpRoute[{}->http://localhost:8080]
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.connection.timeout': 50000
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 - 'http.socket.timeout':
50000
2011-01-08 04:13:16,221 DEBUG RequestAddCookies:131 - CookieSpec selected:
best-match
2011-01-08 04:13:16,222 DEBUG DefaultRequestDirector:445 - Attempt 1 to
execute request
2011-01-08 04:13:16,222 DEBUG DefaultClientConnection:244 - Sending request:
POST /openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=xxxxxxHTTP/1.1
[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Transfer-Encoding: chunked[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Host: localhost:8080[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,223 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=xxxxxxHTTP/1.1
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Transfer-Encoding: chunked
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Host: localhost:8080
2011-01-08 04:13:16,224 DEBUG headers:251 - >> Connection: Keep-Alive
2011-01-08 04:13:16,224 DEBUG wire:78 - >> "d2d[EOL]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Disposition: form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.given_name
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name><patient.family_name
openmrs_table="patient_name"
openmrs_attribute="family_name">Prueba</patient.family_name><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id">4</patient.patient_id><patient.given_name_1
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name_1><patient.family_name_1
openmrs_table="patient_name"
openmrs_attribute="family_name">Rodriguez</patient.family_name_1><encounter.encounter_datetime
openmrs_table="encounter"
openmrs_attribute="encounter_datetime">2011-01-07</encounter.encounter_datetime><encounter.location_id
openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">20</encounter.provider_id><confirmacion_de_identidad
openmrs_concept="6100^confirmacion de identidad^99DCT"
openmrs_datatype="ST">1</confirmacion_de_identidad><confirmacion_dia_de_cumpleanos
openmrs_concept="6101^confirmacion dia de cumpleanos^99DCT"
openmrs_datatype="ST">1</confirmacion_dia_de_cumpleanos><fecha_de_cita
openmrs_concept="6130^fecha de cita^99DCT" openmrs_datatype="DT">2010-03-03</fecha_de_cita><hora_de_cita
openmrs_concept="6129^hora de cita^99DCT" openmrs_datatype="TM"></hora_de_cita><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="ST">1</confirmacion_hora_para_definir_diabetes>"

2011-01-08 04:13:16,227 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "2f[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL--[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "0[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"

Any ideas? tips? I am stuck here now.
Thanks in advance.

Pavel Stephan Muñoz
SSI

··· > ---------- Forwarded message ---------- > From: Daniel Myung > Date: Wed, Dec 29, 2010 at 11:31 AM > Subject: Re: [ODK Community] "HTTP/1.1 411 Length Required" when > trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST > To: opendatakit > > > Hi all, > > ODK along with other OpenROSA submissions transports in chunked > encoding as part of the header, as per the HTTP 1.1 spec. > > From what I gather, Nginx out of the box does not support or honor the > chunked encoding header and fails hard when a content-length header is > not present in an HTTP POST as ODK submits. The 411 error is the > telltale sign of this error. > > I personally ran into this and tried to remedy by using a later > version of nginx (> 0.8.35) > *) Feature: the "chunked_transfer_encoding" directive. > > However, I could not get it to work. I even tried a few workarounds > with different combination of proxy buffering and the like. > > The remedy I've seen online but haven't tried personally is to use the > Chunkin Module which requires rebuilding nginx from source: > > http://wiki.nginx.org/HttpChunkinModule > > Ultimately, this was an issue we had to work around. The current > workaround we use is having all submissions go through apache2 with > mod_proxy. We proxy all posts from port 80 (or 443) on submission, to > a separate internal port (port 81), but add the mod_proxy > environmental variable SetEnv SendCL 1 > (see http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http > ) > > Assuming you can get the POST working with nginx, there is potentially > another problem to contend with. On the return 201 message, that too > may cause a 411 error if there is any body in the 201 response. You > may also need to explicitly set a content length on the response even > it if it is zero or non zero. > > Hope this helps, > Dan > > On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz wrote: > > Hello masters ;), > > > > I have set ODKVoice to upload Xforms to our OpenMRS deployment after each > > call is ended. I did so by editing the UPLOAD_URL string in the > > constants/GlobalConstants class. According to this (from the xforms > module) > > > http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide > > we have two possible URLs to use: > > > http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password > > > http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password > > > > I have tried both options but we are getting a strange error in our > tomcat's > > log. It says: HTTP/1.1 411 Length Required[EOL]. > > Sounds like ODKVoice is not creating proper HTTP headers for this > > transaction; I mean "sounds like", but I doubt it. Other idea I have > about > > possible causes: our tomcat is behind a nginx web server... > > > > Can you bring us a light, as you always do? I am pasting the log here, so > > you can check. > > Thank you all. > > > > Pavel Stephan Muñoz. > > ----------------------------- > > > > 2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending > request: > > POST > > > /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > > HTTP/1.1 > > 2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST > > > /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > > HTTP/1.1[EOL]" > > 2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding: > chunked[EOL]" > > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type: > > multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]" > > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]" > > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]" > > 2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]" > > 2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST > > > /openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > > HTTP/1.1 > > 2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding: chunked > > 2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type: > > multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf > > 2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org > > 2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive > > 2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]" > > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> > > "--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]" > > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition: > form-data; > > name="xml_submission_file"; filename="text/xml"[\r][\n]" > > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type: > > application/octet-stream[\r][\n]" > > 2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding: > > binary[\r][\n]" > > 2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]" > > 2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?> > id="12" name="Llamada de Prueba" version="0.1" > > xmlns:openmrs="formentry.infopath_server_url cannot be > > empty/moduleServlet/formentry/forms/schema/12-1" > > xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" > > xmlns="http://www.w3.org/2002/xforms"> > /> > openmrs_table="patient_name" openmrs_attribute="family_name" > > /> > openmrs_attribute="given_name" /> openmrs_table="patient" > > openmrs_attribute="patient_id" > > /> > openmrs_table="encounter" openmrs_attribute="encounter_datetime" > > /> > > openmrs_attribute="location_id">1 > openmrs_table="encounter" > > openmrs_attribute="provider_id">1 > openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT" > > openmrs_datatype="ZZ"> > openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT" > > openmrs_datatype="NM"> > xmlns:n0="http://www.w3.org/2001/XMLSchema-instance" /> n1:nil="true" > > xmlns:n1="http://www.w3.org/2001/XMLSchema-instance" /> n2:nil="true" > > xmlns:n2="http://www.w3.org/2001/XMLSchema-instance > ">2 > />" > > 2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]" > > 2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]" > > 2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]" > > 2010-12-28 22:27:02,357 DEBUG wire:64 - >> > > "--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]" > > 2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]" > > 2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]" > > 2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]" > > 2010-12-28 22:27:02,358 DEBUG wire:78 - < > Required[EOL]" > > 2010-12-28 22:27:02,358 DEBUG wire:78 - < > 2010-12-28 22:27:02,358 DEBUG wire:78 - < 01:27:13 > > GMT[EOL]" > > 2010-12-28 22:27:02,358 DEBUG wire:78 - < > 2010-12-28 22:27:02,358 DEBUG wire:78 - < > 2010-12-28 22:27:02,358 DEBUG wire:78 - < > 2010-12-28 22:27:02,358 DEBUG wire:78 - < > 2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving > > response: HTTP/1.1 411 Length Required > > 2010-12-28 22:27:02,359 DEBUG headers:232 - < Required > > 2010-12-28 22:27:02,359 DEBUG headers:235 - < > 2010-12-28 22:27:02,359 DEBUG headers:235 - < > 01:27:13 GMT > > 2010-12-28 22:27:02,359 DEBUG headers:235 - < > 2010-12-28 22:27:02,359 DEBUG headers:235 - < > 2010-12-28 22:27:02,359 DEBUG headers:235 - < > 2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 - > > 'http.protocol.handle-redirects': false > > 2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header was > > absent > > 2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload to > > server at > > > http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx > > failed. Will try again in 60000 ms. > > > > -- > > Pavel Stephan Muñoz > > > > -- > > Post: opendatakit@googlegroups.com > > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en > > > > -- > ___________________________________________________________________ > Gerente de Desarrollo, eHealth Systems > Research Fellow, Escuela de Medicina de Harvard > Moderador, GHDOnline.org >

--
Pavel Stephan Muñoz

Hi Pavel,

Could we look at the client side code which makes the openmrs connection to
post this data?

··· On Sat, Jan 8, 2011 at 10:58 AM, Pavel Stephan Muñoz wrote:

Hello everybody.

Thanks all for your kind support.
Daniel Myung was absolutely right, Nginx is not compatible with chunked
encoding. You can read here
http://www.lamnk.com/blog/computer/fix-nginx-411-length-required-error/ if
you are curious.

Anyway, we "bypassed" Nginx and sent data directly to Tomcat in this case.

After solving this issue I ran into 3 o 4 problems maybe, but that does not
matter anymore. Right now Xforms seem to be arriving to OpenMRS, better
said: they at least reach the XformDataUploadManager.processXform(...)method from Xforms module, but then I get the following in OpenMRS's log:

ERROR - XformsUtil.reportDataUploadError(615) |2011-01-08 04:13:16,249|
null
java.lang.NullPointerException
at org.apache.commons.io.IOUtils.toInputStream(IOUtils.java:612)
at
org.openmrs.module.xforms.download.XformDataUploadManager.processXform(XformDataUploadManager.java:88)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doGet(XformDataUploadServlet.java:79)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doPost(XformDataUploadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

It refers to line 88 of XformDataUploadManager where we have:

    public static void processXform(String xml, String sessionId,

String enterer, boolean propagateErrors,HttpServletRequest request) throws
Exception{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc =
db.parse(IOUtils.toInputStream(xml,XformConstants.DEFAULT_CHARACTER_ENCODING));
setHeaderValues(doc,sessionId,enterer);

queueForm(XformsUtil.doc2String(doc),propagateErrors,request);
}

I have commons-io-1.4.jar, if that's useful to know.
This is shown in ODKVoice's log after a call is completed:

2011-01-08 04:13:16,209 INFO FormVxmlRenderer:317 - Set outbound status:
id=80; status=COMPLETE
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
2011-01-08 04:13:16,211 INFO FormVxmlRenderer:760 - Export data path:
/root/odkvoicedata/instances/+50588367336/1294470742015
2011-01-08 04:13:16,212 INFO FormVxmlRenderer:764 - XML path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
Path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
2011-01-08 04:13:16,213 INFO FormVxmlRenderer:784 - Queued
InstanceUploaderThread
2011-01-08 04:13:16,214 INFO FormVxmlRenderer:802 - About to upload
instance to
http://localhost:8080/openmrs_devel/moduleServlet/xforms/xformDataUpload?
uname=xxxxxx&pw=xxxxxx
2011-01-08 04:13:16,219 DEBUG SingleClientConnManager:195 - Get connection
for route HttpRoute[{}->http://localhost:8080]
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.connection.timeout': 50000
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.socket.timeout': 50000
2011-01-08 04:13:16,221 DEBUG RequestAddCookies:131 - CookieSpec selected:
best-match
2011-01-08 04:13:16,222 DEBUG DefaultRequestDirector:445 - Attempt 1 to
execute request
2011-01-08 04:13:16,222 DEBUG DefaultClientConnection:244 - Sending
request: POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=xxxxxxHTTP/1.1
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=xxxxxxHTTP/1.1
[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Host: localhost:8080[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,223 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=xxxxxxHTTP/1.1
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Transfer-Encoding: chunked
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Host: localhost:8080
2011-01-08 04:13:16,224 DEBUG headers:251 - >> Connection: Keep-Alive
2011-01-08 04:13:16,224 DEBUG wire:78 - >> "d2d[EOL]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Disposition: form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.given_name
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name><patient.family_name
openmrs_table="patient_name"
openmrs_attribute="family_name">Prueba</patient.family_name><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id">4</patient.patient_id><patient.given_name_1
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name_1><patient.family_name_1
openmrs_table="patient_name"
openmrs_attribute="family_name">Rodriguez</patient.family_name_1><encounter.encounter_datetime
openmrs_table="encounter"
openmrs_attribute="encounter_datetime">2011-01-07</encounter.encounter_datetime><encounter.location_id
openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">20</encounter.provider_id><confirmacion_de_identidad
openmrs_concept="6100^confirmacion de identidad^99DCT"
openmrs_datatype="ST">1</confirmacion_de_identidad><confirmacion_dia_de_cumpleanos
openmrs_concept="6101^confirmacion dia de cumpleanos^99DCT"
openmrs_datatype="ST">1</confirmacion_dia_de_cumpleanos><fecha_de_cita
openmrs_concept="6130^fecha de cita^99DCT" openmrs_datatype="DT">2010-03-03</fecha_de_cita><hora_de_cita
openmrs_concept="6129^hora de cita^99DCT" openmrs_datatype="TM"></hora_de_cita><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="ST">1</confirmacion_hora_para_definir_diabetes>"

2011-01-08 04:13:16,227 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "2f[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL--[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "0[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"

Any ideas? tips? I am stuck here now.
Thanks in advance.

Pavel Stephan Muñoz
SSI

---------- Forwarded message ----------
From: Daniel Myung dmyung@dimagi.com
Date: Wed, Dec 29, 2010 at 11:31 AM
Subject: Re: [ODK Community] "HTTP/1.1 411 Length Required" when
trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST
To: opendatakit opendatakit@googlegroups.com

Hi all,

ODK along with other OpenROSA submissions transports in chunked
encoding as part of the header, as per the HTTP 1.1 spec.

From what I gather, Nginx out of the box does not support or honor the
chunked encoding header and fails hard when a content-length header is
not present in an HTTP POST as ODK submits. The 411 error is the
telltale sign of this error.

I personally ran into this and tried to remedy by using a later
version of nginx (> 0.8.35)
*) Feature: the "chunked_transfer_encoding" directive.

However, I could not get it to work. I even tried a few workarounds
with different combination of proxy buffering and the like.

The remedy I've seen online but haven't tried personally is to use the
Chunkin Module which requires rebuilding nginx from source:

http://wiki.nginx.org/HttpChunkinModule

Ultimately, this was an issue we had to work around. The current
workaround we use is having all submissions go through apache2 with
mod_proxy. We proxy all posts from port 80 (or 443) on submission, to
a separate internal port (port 81), but add the mod_proxy
environmental variable SetEnv SendCL 1
(see
http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http)

Assuming you can get the POST working with nginx, there is potentially
another problem to contend with. On the return 201 message, that too
may cause a 411 error if there is any body in the 201 response. You
may also need to explicitly set a content length on the response even
it if it is zero or non zero.

Hope this helps,
Dan

On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz minibota@gmail.com wrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after
each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)

http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide

we have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password

http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's
log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have
about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log here,
so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request:
POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition:
form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered
/><patient.family_name
openmrs_table="patient_name" openmrs_attribute="family_name"
/><patient.given_name openmrs_table="patient_name"
openmrs_attribute="given_name" /><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"

openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id

openmrs_table="encounter"

openmrs_attribute="provider_id">1</encounter.provider_id><obs

openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT"
openmrs_datatype="ZZ"><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server: nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010
01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type:
text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length: 181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving
response: HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length
Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec 2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type: text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload to
server at

http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

failed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--


Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

Hello Daniel, sorry for replying late.

I believe this is what you are asking for. This is were ODKVoice posts the
data to OpenMRS, the InstanceUploader class:
https://code.google.com/r/minibota-ehs/source/browse/src/org/odk/voice/storage/InstanceUploader.java?r=8765ff97f99176fc6e19bb775be4983db781487c

Thanks!

··· 2011/1/8 Daniel Kayiwa

Hi Pavel,

Could we look at the client side code which makes the openmrs connection to
post this data?

On Sat, Jan 8, 2011 at 10:58 AM, Pavel Stephan Muñoz minibota@gmail.comwrote:

Hello everybody.

Thanks all for your kind support.
Daniel Myung was absolutely right, Nginx is not compatible with chunked
encoding. You can read here
http://www.lamnk.com/blog/computer/fix-nginx-411-length-required-error/if you are curious.

Anyway, we "bypassed" Nginx and sent data directly to Tomcat in this case.

After solving this issue I ran into 3 o 4 problems maybe, but that does
not matter anymore. Right now Xforms seem to be arriving to OpenMRS, better
said: they at least reach the XformDataUploadManager.processXform(...)method from Xforms module, but then I get the following in OpenMRS's log:

ERROR - XformsUtil.reportDataUploadError(615) |2011-01-08 04:13:16,249|
null
java.lang.NullPointerException
at org.apache.commons.io.IOUtils.toInputStream(IOUtils.java:612)
at
org.openmrs.module.xforms.download.XformDataUploadManager.processXform(XformDataUploadManager.java:88)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doGet(XformDataUploadServlet.java:79)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doPost(XformDataUploadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

It refers to line 88 of XformDataUploadManager where we have:

    public static void processXform(String xml, String sessionId,

String enterer, boolean propagateErrors,HttpServletRequest request) throws
Exception{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc =
db.parse(IOUtils.toInputStream(xml,XformConstants.DEFAULT_CHARACTER_ENCODING));
setHeaderValues(doc,sessionId,enterer);

queueForm(XformsUtil.doc2String(doc),propagateErrors,request);
}

I have commons-io-1.4.jar, if that's useful to know.
This is shown in ODKVoice's log after a call is completed:

2011-01-08 04:13:16,209 INFO FormVxmlRenderer:317 - Set outbound status:
id=80; status=COMPLETE
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
2011-01-08 04:13:16,211 INFO FormVxmlRenderer:760 - Export data path:
/root/odkvoicedata/instances/+50588367336/1294470742015
2011-01-08 04:13:16,212 INFO FormVxmlRenderer:764 - XML path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
Path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
2011-01-08 04:13:16,213 INFO FormVxmlRenderer:784 - Queued
InstanceUploaderThread
2011-01-08 04:13:16,214 INFO FormVxmlRenderer:802 - About to upload
instance to
http://localhost:8080/openmrs_devel/moduleServlet/xforms/xformDataUpload?
uname=xxxxxx&pw=xxxxxx
2011-01-08 04:13:16,219 DEBUG SingleClientConnManager:195 - Get connection
for route HttpRoute[{}->http://localhost:8080]
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.connection.timeout': 50000
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.socket.timeout': 50000
2011-01-08 04:13:16,221 DEBUG RequestAddCookies:131 - CookieSpec selected:
best-match
2011-01-08 04:13:16,222 DEBUG DefaultRequestDirector:445 - Attempt 1 to
execute request
2011-01-08 04:13:16,222 DEBUG DefaultClientConnection:244 - Sending
request: POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Host: localhost:8080[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,223 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Transfer-Encoding: chunked
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Host: localhost:8080
2011-01-08 04:13:16,224 DEBUG headers:251 - >> Connection: Keep-Alive
2011-01-08 04:13:16,224 DEBUG wire:78 - >> "d2d[EOL]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Disposition:
form-data; name="xml_submission_file"; filename="text/xml"[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.given_name
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name><patient.family_name
openmrs_table="patient_name"
openmrs_attribute="family_name">Prueba</patient.family_name><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id">4</patient.patient_id><patient.given_name_1
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name_1><patient.family_name_1
openmrs_table="patient_name"
openmrs_attribute="family_name">Rodriguez</patient.family_name_1><encounter.encounter_datetime
openmrs_table="encounter"
openmrs_attribute="encounter_datetime">2011-01-07</encounter.encounter_datetime><encounter.location_id
openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">20</encounter.provider_id><confirmacion_de_identidad
openmrs_concept="6100^confirmacion de identidad^99DCT"
openmrs_datatype="ST">1</confirmacion_de_identidad><confirmacion_dia_de_cumpleanos
openmrs_concept="6101^confirmacion dia de cumpleanos^99DCT"
openmrs_datatype="ST">1</confirmacion_dia_de_cumpleanos><fecha_de_cita
openmrs_concept="6130^fecha de cita^99DCT" openmrs_datatype="DT">2010-03-03</fecha_de_cita><hora_de_cita
openmrs_concept="6129^hora de cita^99DCT" openmrs_datatype="TM"></hora_de_cita><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="ST">1</confirmacion_hora_para_definir_diabetes>"

2011-01-08 04:13:16,227 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "2f[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL--[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "0[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"

Any ideas? tips? I am stuck here now.
Thanks in advance.

Pavel Stephan Muñoz
SSI

---------- Forwarded message ----------
From: Daniel Myung dmyung@dimagi.com
Date: Wed, Dec 29, 2010 at 11:31 AM
Subject: Re: [ODK Community] "HTTP/1.1 411 Length Required" when
trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST
To: opendatakit opendatakit@googlegroups.com

Hi all,

ODK along with other OpenROSA submissions transports in chunked
encoding as part of the header, as per the HTTP 1.1 spec.

From what I gather, Nginx out of the box does not support or honor the
chunked encoding header and fails hard when a content-length header is
not present in an HTTP POST as ODK submits. The 411 error is the
telltale sign of this error.

I personally ran into this and tried to remedy by using a later
version of nginx (> 0.8.35)
*) Feature: the "chunked_transfer_encoding" directive.

However, I could not get it to work. I even tried a few workarounds
with different combination of proxy buffering and the like.

The remedy I've seen online but haven't tried personally is to use the
Chunkin Module which requires rebuilding nginx from source:

http://wiki.nginx.org/HttpChunkinModule

Ultimately, this was an issue we had to work around. The current
workaround we use is having all submissions go through apache2 with
mod_proxy. We proxy all posts from port 80 (or 443) on submission, to
a separate internal port (port 81), but add the mod_proxy
environmental variable SetEnv SendCL 1
(see
http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http)

Assuming you can get the POST working with nginx, there is potentially
another problem to contend with. On the return 201 message, that too
may cause a 411 error if there is any body in the 201 response. You
may also need to explicitly set a content length on the response even
it if it is zero or non zero.

Hope this helps,
Dan

On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz minibota@gmail.com wrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after
each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)

http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide

we have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password

http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's
log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have
about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log here,
so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request:
POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection:
Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition:
form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered
/><patient.family_name
openmrs_table="patient_name" openmrs_attribute="family_name"
/><patient.given_name openmrs_table="patient_name"
openmrs_attribute="given_name" /><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"

openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id

openmrs_table="encounter"

openmrs_attribute="provider_id">1</encounter.provider_id><obs

openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT"
openmrs_datatype="ZZ"><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server: nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010
01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type:
text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length: 181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving
response: HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length
Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec 2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type: text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header
was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload to
server at

http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

failed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--


Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

Am not very sure if this is caused by change from "FileBody" to
"InputStreamBody" for "xml_submission_file"
Just for troubleshooting, does it work if you used "FileBody"?

··· On Tue, Jan 11, 2011 at 8:33 AM, Pavel Stephan Muñoz wrote:

Hello Daniel, sorry for replying late.

I believe this is what you are asking for. This is were ODKVoice posts the
data to OpenMRS, the InstanceUploader class:

https://code.google.com/r/minibota-ehs/source/browse/src/org/odk/voice/storage/InstanceUploader.java?r=8765ff97f99176fc6e19bb775be4983db781487c

Thanks!

2011/1/8 Daniel Kayiwa kayiwadaniel@gmail.com

Hi Pavel,

Could we look at the client side code which makes the openmrs connection
to post this data?

On Sat, Jan 8, 2011 at 10:58 AM, Pavel Stephan Muñoz minibota@gmail.comwrote:

Hello everybody.

Thanks all for your kind support.
Daniel Myung was absolutely right, Nginx is not compatible with chunked
encoding. You can read here
http://www.lamnk.com/blog/computer/fix-nginx-411-length-required-error/if you are curious.

Anyway, we "bypassed" Nginx and sent data directly to Tomcat in this
case.

After solving this issue I ran into 3 o 4 problems maybe, but that does
not matter anymore. Right now Xforms seem to be arriving to OpenMRS, better
said: they at least reach the XformDataUploadManager.processXform(...)method from Xforms module, but then I get the following in OpenMRS's log:

ERROR - XformsUtil.reportDataUploadError(615) |2011-01-08 04:13:16,249|
null
java.lang.NullPointerException
at org.apache.commons.io.IOUtils.toInputStream(IOUtils.java:612)
at
org.openmrs.module.xforms.download.XformDataUploadManager.processXform(XformDataUploadManager.java:88)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doGet(XformDataUploadServlet.java:79)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doPost(XformDataUploadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

It refers to line 88 of XformDataUploadManager where we have:

    public static void processXform(String xml, String sessionId,

String enterer, boolean propagateErrors,HttpServletRequest request) throws
Exception{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc =
db.parse(IOUtils.toInputStream(xml,XformConstants.DEFAULT_CHARACTER_ENCODING));
setHeaderValues(doc,sessionId,enterer);

queueForm(XformsUtil.doc2String(doc),propagateErrors,request);
}

I have commons-io-1.4.jar, if that's useful to know.
This is shown in ODKVoice's log after a call is completed:

2011-01-08 04:13:16,209 INFO FormVxmlRenderer:317 - Set outbound status:
id=80; status=COMPLETE
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
2011-01-08 04:13:16,211 INFO FormVxmlRenderer:760 - Export data path:
/root/odkvoicedata/instances/+50588367336/1294470742015
2011-01-08 04:13:16,212 INFO FormVxmlRenderer:764 - XML path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
Path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
2011-01-08 04:13:16,213 INFO FormVxmlRenderer:784 - Queued
InstanceUploaderThread
2011-01-08 04:13:16,214 INFO FormVxmlRenderer:802 - About to upload
instance to
http://localhost:8080/openmrs_devel/moduleServlet/xforms/xformDataUpload
?uname=xxxxxx&pw=xxxxxx
2011-01-08 04:13:16,219 DEBUG SingleClientConnManager:195 - Get
connection for route HttpRoute[{}->http://localhost:8080]
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.connection.timeout': 50000
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.socket.timeout': 50000
2011-01-08 04:13:16,221 DEBUG RequestAddCookies:131 - CookieSpec
selected: best-match
2011-01-08 04:13:16,222 DEBUG DefaultRequestDirector:445 - Attempt 1 to
execute request
2011-01-08 04:13:16,222 DEBUG DefaultClientConnection:244 - Sending
request: POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Host: localhost:8080[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,223 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Transfer-Encoding: chunked
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Host: localhost:8080
2011-01-08 04:13:16,224 DEBUG headers:251 - >> Connection: Keep-Alive
2011-01-08 04:13:16,224 DEBUG wire:78 - >> "d2d[EOL]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Disposition:
form-data; name="xml_submission_file"; filename="text/xml"[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.given_name
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name><patient.family_name
openmrs_table="patient_name"
openmrs_attribute="family_name">Prueba</patient.family_name><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id">4</patient.patient_id><patient.given_name_1
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name_1><patient.family_name_1
openmrs_table="patient_name"
openmrs_attribute="family_name">Rodriguez</patient.family_name_1><encounter.encounter_datetime
openmrs_table="encounter"
openmrs_attribute="encounter_datetime">2011-01-07</encounter.encounter_datetime><encounter.location_id
openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">20</encounter.provider_id><confirmacion_de_identidad
openmrs_concept="6100^confirmacion de identidad^99DCT"
openmrs_datatype="ST">1</confirmacion_de_identidad><confirmacion_dia_de_cumpleanos
openmrs_concept="6101^confirmacion dia de cumpleanos^99DCT"
openmrs_datatype="ST">1</confirmacion_dia_de_cumpleanos><fecha_de_cita
openmrs_concept="6130^fecha de cita^99DCT" openmrs_datatype="DT">2010-03-03</fecha_de_cita><hora_de_cita
openmrs_concept="6129^hora de cita^99DCT" openmrs_datatype="TM"></hora_de_cita><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="ST">1</confirmacion_hora_para_definir_diabetes>"

2011-01-08 04:13:16,227 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "2f[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL--[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "0[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"

Any ideas? tips? I am stuck here now.
Thanks in advance.

Pavel Stephan Muñoz
SSI

---------- Forwarded message ----------
From: Daniel Myung dmyung@dimagi.com
Date: Wed, Dec 29, 2010 at 11:31 AM
Subject: Re: [ODK Community] "HTTP/1.1 411 Length Required" when
trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST
To: opendatakit opendatakit@googlegroups.com

Hi all,

ODK along with other OpenROSA submissions transports in chunked
encoding as part of the header, as per the HTTP 1.1 spec.

From what I gather, Nginx out of the box does not support or honor the
chunked encoding header and fails hard when a content-length header is
not present in an HTTP POST as ODK submits. The 411 error is the
telltale sign of this error.

I personally ran into this and tried to remedy by using a later
version of nginx (> 0.8.35)
*) Feature: the "chunked_transfer_encoding" directive.

However, I could not get it to work. I even tried a few workarounds
with different combination of proxy buffering and the like.

The remedy I've seen online but haven't tried personally is to use the
Chunkin Module which requires rebuilding nginx from source:

http://wiki.nginx.org/HttpChunkinModule

Ultimately, this was an issue we had to work around. The current
workaround we use is having all submissions go through apache2 with
mod_proxy. We proxy all posts from port 80 (or 443) on submission, to
a separate internal port (port 81), but add the mod_proxy
environmental variable SetEnv SendCL 1
(see
http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http)

Assuming you can get the POST working with nginx, there is potentially
another problem to contend with. On the return 201 message, that too
may cause a 411 error if there is any body in the 201 response. You
may also need to explicitly set a content length on the response even
it if it is zero or non zero.

Hope this helps,
Dan

On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz minibota@gmail.com wrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after
each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)

http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide

we have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password

http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's
log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have
about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log here,
so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request:
POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data;
boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection:
Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition:
form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered
/><patient.family_name
openmrs_table="patient_name" openmrs_attribute="family_name"
/><patient.given_name openmrs_table="patient_name"
openmrs_attribute="given_name" /><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"

openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id

openmrs_table="encounter"

openmrs_attribute="provider_id">1</encounter.provider_id><obs

openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT"
openmrs_datatype="ZZ"><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server: nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010
01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type:
text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length: 181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving
response: HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length
Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec 2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type: text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header
was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload
to
server at

http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

failed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--


Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

Let me test that later.
Thanks for the tip, I will let you know if that helps.

··· 2011/1/11 Daniel Kayiwa

Am not very sure if this is caused by change from "FileBody" to
"InputStreamBody" for "xml_submission_file"
Just for troubleshooting, does it work if you used "FileBody"?

On Tue, Jan 11, 2011 at 8:33 AM, Pavel Stephan Muñoz minibota@gmail.comwrote:

Hello Daniel, sorry for replying late.

I believe this is what you are asking for. This is were ODKVoice posts the
data to OpenMRS, the InstanceUploader class:

https://code.google.com/r/minibota-ehs/source/browse/src/org/odk/voice/storage/InstanceUploader.java?r=8765ff97f99176fc6e19bb775be4983db781487c

Thanks!

2011/1/8 Daniel Kayiwa kayiwadaniel@gmail.com

Hi Pavel,

Could we look at the client side code which makes the openmrs connection
to post this data?

On Sat, Jan 8, 2011 at 10:58 AM, Pavel Stephan Muñoz <minibota@gmail.com wrote:

Hello everybody.

Thanks all for your kind support.
Daniel Myung was absolutely right, Nginx is not compatible with chunked
encoding. You can read here
http://www.lamnk.com/blog/computer/fix-nginx-411-length-required-error/if you are curious.

Anyway, we "bypassed" Nginx and sent data directly to Tomcat in this
case.

After solving this issue I ran into 3 o 4 problems maybe, but that does
not matter anymore. Right now Xforms seem to be arriving to OpenMRS, better
said: they at least reach the XformDataUploadManager.processXform(...)method from Xforms module, but then I get the following in OpenMRS's log:

ERROR - XformsUtil.reportDataUploadError(615) |2011-01-08 04:13:16,249|
null
java.lang.NullPointerException
at org.apache.commons.io.IOUtils.toInputStream(IOUtils.java:612)
at
org.openmrs.module.xforms.download.XformDataUploadManager.processXform(XformDataUploadManager.java:88)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doGet(XformDataUploadServlet.java:79)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doPost(XformDataUploadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

It refers to line 88 of XformDataUploadManager where we have:

    public static void processXform(String xml, String sessionId,

String enterer, boolean propagateErrors,HttpServletRequest request) throws
Exception{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc =
db.parse(IOUtils.toInputStream(xml,XformConstants.DEFAULT_CHARACTER_ENCODING));
setHeaderValues(doc,sessionId,enterer);

queueForm(XformsUtil.doc2String(doc),propagateErrors,request);
}

I have commons-io-1.4.jar, if that's useful to know.
This is shown in ODKVoice's log after a call is completed:

2011-01-08 04:13:16,209 INFO FormVxmlRenderer:317 - Set outbound
status: id=80; status=COMPLETE
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
2011-01-08 04:13:16,211 INFO FormVxmlRenderer:760 - Export data path:
/root/odkvoicedata/instances/+50588367336/1294470742015
2011-01-08 04:13:16,212 INFO FormVxmlRenderer:764 - XML path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
Path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
2011-01-08 04:13:16,213 INFO FormVxmlRenderer:784 - Queued
InstanceUploaderThread
2011-01-08 04:13:16,214 INFO FormVxmlRenderer:802 - About to upload
instance to
http://localhost:8080/openmrs_devel/moduleServlet/xforms/xformDataUpload
?uname=xxxxxx&pw=xxxxxx
2011-01-08 04:13:16,219 DEBUG SingleClientConnManager:195 - Get
connection for route HttpRoute[{}->http://localhost:8080]
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.connection.timeout': 50000
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.socket.timeout': 50000
2011-01-08 04:13:16,221 DEBUG RequestAddCookies:131 - CookieSpec
selected: best-match
2011-01-08 04:13:16,222 DEBUG DefaultRequestDirector:445 - Attempt 1 to
execute request
2011-01-08 04:13:16,222 DEBUG DefaultClientConnection:244 - Sending
request: POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Host: localhost:8080[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "Connection: Keep-Alive[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,223 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Host: localhost:8080
2011-01-08 04:13:16,224 DEBUG headers:251 - >> Connection: Keep-Alive
2011-01-08 04:13:16,224 DEBUG wire:78 - >> "d2d[EOL]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Disposition:
form-data; name="xml_submission_file"; filename="text/xml"[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.given_name
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name><patient.family_name
openmrs_table="patient_name"
openmrs_attribute="family_name">Prueba</patient.family_name><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id">4</patient.patient_id><patient.given_name_1
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name_1><patient.family_name_1
openmrs_table="patient_name"
openmrs_attribute="family_name">Rodriguez</patient.family_name_1><encounter.encounter_datetime
openmrs_table="encounter"
openmrs_attribute="encounter_datetime">2011-01-07</encounter.encounter_datetime><encounter.location_id
openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">20</encounter.provider_id><confirmacion_de_identidad
openmrs_concept="6100^confirmacion de identidad^99DCT"
openmrs_datatype="ST">1</confirmacion_de_identidad><confirmacion_dia_de_cumpleanos
openmrs_concept="6101^confirmacion dia de cumpleanos^99DCT"
openmrs_datatype="ST">1</confirmacion_dia_de_cumpleanos><fecha_de_cita
openmrs_concept="6130^fecha de cita^99DCT" openmrs_datatype="DT">2010-03-03</fecha_de_cita><hora_de_cita
openmrs_concept="6129^hora de cita^99DCT" openmrs_datatype="TM"></hora_de_cita><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="ST">1</confirmacion_hora_para_definir_diabetes>"

2011-01-08 04:13:16,227 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "2f[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL--[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "0[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"

Any ideas? tips? I am stuck here now.
Thanks in advance.

Pavel Stephan Muñoz
SSI

---------- Forwarded message ----------
From: Daniel Myung dmyung@dimagi.com
Date: Wed, Dec 29, 2010 at 11:31 AM
Subject: Re: [ODK Community] "HTTP/1.1 411 Length Required" when
trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST
To: opendatakit opendatakit@googlegroups.com

Hi all,

ODK along with other OpenROSA submissions transports in chunked
encoding as part of the header, as per the HTTP 1.1 spec.

From what I gather, Nginx out of the box does not support or honor the
chunked encoding header and fails hard when a content-length header is
not present in an HTTP POST as ODK submits. The 411 error is the
telltale sign of this error.

I personally ran into this and tried to remedy by using a later
version of nginx (> 0.8.35)
*) Feature: the "chunked_transfer_encoding" directive.

However, I could not get it to work. I even tried a few workarounds
with different combination of proxy buffering and the like.

The remedy I've seen online but haven't tried personally is to use the
Chunkin Module which requires rebuilding nginx from source:

http://wiki.nginx.org/HttpChunkinModule

Ultimately, this was an issue we had to work around. The current
workaround we use is having all submissions go through apache2 with
mod_proxy. We proxy all posts from port 80 (or 443) on submission, to
a separate internal port (port 81), but add the mod_proxy
environmental variable SetEnv SendCL 1
(see
http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http)

Assuming you can get the POST working with nginx, there is potentially
another problem to contend with. On the return 201 message, that too
may cause a 411 error if there is any body in the 201 response. You
may also need to explicitly set a content length on the response even
it if it is zero or non zero.

Hope this helps,
Dan

On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz minibota@gmail.com wrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after
each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)

http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide

we have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password

http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's
log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have
about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log
here, so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request:
POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data;
boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org
[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection:
Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection: Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition:
form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered
/><patient.family_name
openmrs_table="patient_name" openmrs_attribute="family_name"
/><patient.given_name openmrs_table="patient_name"
openmrs_attribute="given_name" /><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"

openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id

openmrs_table="encounter"

openmrs_attribute="provider_id">1</encounter.provider_id><obs

openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT"
openmrs_datatype="ZZ"><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server:
nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010
01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type:
text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length: 181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 - Receiving
response: HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length
Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec 2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type:
text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header
was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload
to
server at

http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

failed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--


Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others,
we shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

Hello Daniel,

It worked perfectly with FileBody, we will keep it that way.
Thank you a lot!

Pavel Stephan Muñoz

··· 2011/1/11 Pavel Stephan Muñoz

Let me test that later.
Thanks for the tip, I will let you know if that helps.

2011/1/11 Daniel Kayiwa kayiwadaniel@gmail.com

Am not very sure if this is caused by change from "FileBody" to
"InputStreamBody" for "xml_submission_file"
Just for troubleshooting, does it work if you used "FileBody"?

On Tue, Jan 11, 2011 at 8:33 AM, Pavel Stephan Muñoz minibota@gmail.comwrote:

Hello Daniel, sorry for replying late.

I believe this is what you are asking for. This is were ODKVoice posts
the data to OpenMRS, the InstanceUploader class:

https://code.google.com/r/minibota-ehs/source/browse/src/org/odk/voice/storage/InstanceUploader.java?r=8765ff97f99176fc6e19bb775be4983db781487c

Thanks!

2011/1/8 Daniel Kayiwa kayiwadaniel@gmail.com

Hi Pavel,

Could we look at the client side code which makes the openmrs connection
to post this data?

On Sat, Jan 8, 2011 at 10:58 AM, Pavel Stephan Muñoz < minibota@gmail.com> wrote:

Hello everybody.

Thanks all for your kind support.
Daniel Myung was absolutely right, Nginx is not compatible with chunked
encoding. You can read here
http://www.lamnk.com/blog/computer/fix-nginx-411-length-required-error/if you are curious.

Anyway, we "bypassed" Nginx and sent data directly to Tomcat in this
case.

After solving this issue I ran into 3 o 4 problems maybe, but that does
not matter anymore. Right now Xforms seem to be arriving to OpenMRS, better
said: they at least reach the XformDataUploadManager.processXform(...)method from Xforms module, but then I get the following in OpenMRS's log:

ERROR - XformsUtil.reportDataUploadError(615) |2011-01-08 04:13:16,249|
null
java.lang.NullPointerException
at org.apache.commons.io.IOUtils.toInputStream(IOUtils.java:612)
at
org.openmrs.module.xforms.download.XformDataUploadManager.processXform(XformDataUploadManager.java:88)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doGet(XformDataUploadServlet.java:79)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doPost(XformDataUploadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

It refers to line 88 of XformDataUploadManager where we have:

    public static void processXform(String xml, String sessionId,

String enterer, boolean propagateErrors,HttpServletRequest request) throws
Exception{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc =
db.parse(IOUtils.toInputStream(xml,XformConstants.DEFAULT_CHARACTER_ENCODING));
setHeaderValues(doc,sessionId,enterer);

queueForm(XformsUtil.doc2String(doc),propagateErrors,request);
}

I have commons-io-1.4.jar, if that's useful to know.
This is shown in ODKVoice's log after a call is completed:

2011-01-08 04:13:16,209 INFO FormVxmlRenderer:317 - Set outbound
status: id=80; status=COMPLETE
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
2011-01-08 04:13:16,211 INFO FormVxmlRenderer:760 - Export data path:
/root/odkvoicedata/instances/+50588367336/1294470742015
2011-01-08 04:13:16,212 INFO FormVxmlRenderer:764 - XML path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
Path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
2011-01-08 04:13:16,213 INFO FormVxmlRenderer:784 - Queued
InstanceUploaderThread
2011-01-08 04:13:16,214 INFO FormVxmlRenderer:802 - About to upload
instance to
http://localhost:8080/openmrs_devel/moduleServlet/xforms/xformDataUpload
?uname=xxxxxx&pw=xxxxxx
2011-01-08 04:13:16,219 DEBUG SingleClientConnManager:195 - Get
connection for route HttpRoute[{}->http://localhost:8080]
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.connection.timeout': 50000
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.socket.timeout': 50000
2011-01-08 04:13:16,221 DEBUG RequestAddCookies:131 - CookieSpec
selected: best-match
2011-01-08 04:13:16,222 DEBUG DefaultRequestDirector:445 - Attempt 1 to
execute request
2011-01-08 04:13:16,222 DEBUG DefaultClientConnection:244 - Sending
request: POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Host: localhost:8080[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "Connection:
Keep-Alive[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,223 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Host: localhost:8080
2011-01-08 04:13:16,224 DEBUG headers:251 - >> Connection: Keep-Alive
2011-01-08 04:13:16,224 DEBUG wire:78 - >> "d2d[EOL]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Disposition:
form-data; name="xml_submission_file"; filename="text/xml"[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.given_name
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name><patient.family_name
openmrs_table="patient_name"
openmrs_attribute="family_name">Prueba</patient.family_name><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id">4</patient.patient_id><patient.given_name_1
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name_1><patient.family_name_1
openmrs_table="patient_name"
openmrs_attribute="family_name">Rodriguez</patient.family_name_1><encounter.encounter_datetime
openmrs_table="encounter"
openmrs_attribute="encounter_datetime">2011-01-07</encounter.encounter_datetime><encounter.location_id
openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">20</encounter.provider_id><confirmacion_de_identidad
openmrs_concept="6100^confirmacion de identidad^99DCT"
openmrs_datatype="ST">1</confirmacion_de_identidad><confirmacion_dia_de_cumpleanos
openmrs_concept="6101^confirmacion dia de cumpleanos^99DCT"
openmrs_datatype="ST">1</confirmacion_dia_de_cumpleanos><fecha_de_cita
openmrs_concept="6130^fecha de cita^99DCT" openmrs_datatype="DT">2010-03-03</fecha_de_cita><hora_de_cita
openmrs_concept="6129^hora de cita^99DCT" openmrs_datatype="TM"></hora_de_cita><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="ST">1</confirmacion_hora_para_definir_diabetes>"

2011-01-08 04:13:16,227 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "2f[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL--[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "0[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"

Any ideas? tips? I am stuck here now.
Thanks in advance.

Pavel Stephan Muñoz
SSI

---------- Forwarded message ----------
From: Daniel Myung dmyung@dimagi.com
Date: Wed, Dec 29, 2010 at 11:31 AM
Subject: Re: [ODK Community] "HTTP/1.1 411 Length Required" when
trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST
To: opendatakit opendatakit@googlegroups.com

Hi all,

ODK along with other OpenROSA submissions transports in chunked
encoding as part of the header, as per the HTTP 1.1 spec.

From what I gather, Nginx out of the box does not support or honor the
chunked encoding header and fails hard when a content-length header is
not present in an HTTP POST as ODK submits. The 411 error is the
telltale sign of this error.

I personally ran into this and tried to remedy by using a later
version of nginx (> 0.8.35)
*) Feature: the "chunked_transfer_encoding" directive.

However, I could not get it to work. I even tried a few workarounds
with different combination of proxy buffering and the like.

The remedy I've seen online but haven't tried personally is to use the
Chunkin Module which requires rebuilding nginx from source:

http://wiki.nginx.org/HttpChunkinModule

Ultimately, this was an issue we had to work around. The current
workaround we use is having all submissions go through apache2 with
mod_proxy. We proxy all posts from port 80 (or 443) on submission, to
a separate internal port (port 81), but add the mod_proxy
environmental variable SetEnv SendCL 1
(see
http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http)

Assuming you can get the POST working with nginx, there is potentially
another problem to contend with. On the return 201 message, that too
may cause a 411 error if there is any body in the 201 response. You
may also need to explicitly set a content length on the response even
it if it is zero or non zero.

Hope this helps,
Dan

On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz minibota@gmail.com wrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment after
each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)

http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide

we have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password

http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's
log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I have
about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log
here, so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request:
POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data;
boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org
[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection:
Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection:
Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition:
form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered
/><patient.family_name
openmrs_table="patient_name" openmrs_attribute="family_name"
/><patient.given_name openmrs_table="patient_name"
openmrs_attribute="given_name" /><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"

openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id

openmrs_table="encounter"

openmrs_attribute="provider_id">1</encounter.provider_id><obs

openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT"
openmrs_datatype="ZZ"><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server:
nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010
01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type:
text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length:
181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 -
Receiving
response: HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length
Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec
2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type:
text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location header
was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance upload
to
server at

http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

failed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--


Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others,
we shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

--
Pavel Stephan Muñoz

Thanks so much Pavel for the feedback!!!
Will get some time and try figure out what it takes to make InputStreamBody
also work.

··· On Thu, Jan 20, 2011 at 1:14 AM, Pavel Stephan Muñoz wrote:

Hello Daniel,

It worked perfectly with FileBody, we will keep it that way.
Thank you a lot!

Pavel Stephan Muñoz

2011/1/11 Pavel Stephan Muñoz minibota@gmail.com

Let me test that later.

Thanks for the tip, I will let you know if that helps.

2011/1/11 Daniel Kayiwa kayiwadaniel@gmail.com

Am not very sure if this is caused by change from "FileBody" to
"InputStreamBody" for "xml_submission_file"
Just for troubleshooting, does it work if you used "FileBody"?

On Tue, Jan 11, 2011 at 8:33 AM, Pavel Stephan Muñoz <minibota@gmail.com wrote:

Hello Daniel, sorry for replying late.

I believe this is what you are asking for. This is were ODKVoice posts
the data to OpenMRS, the InstanceUploader class:

https://code.google.com/r/minibota-ehs/source/browse/src/org/odk/voice/storage/InstanceUploader.java?r=8765ff97f99176fc6e19bb775be4983db781487c

Thanks!

2011/1/8 Daniel Kayiwa kayiwadaniel@gmail.com

Hi Pavel,

Could we look at the client side code which makes the openmrs
connection to post this data?

On Sat, Jan 8, 2011 at 10:58 AM, Pavel Stephan Muñoz < minibota@gmail.com> wrote:

Hello everybody.

Thanks all for your kind support.
Daniel Myung was absolutely right, Nginx is not compatible with
chunked encoding. You can read here
http://www.lamnk.com/blog/computer/fix-nginx-411-length-required-error/if you are curious.

Anyway, we "bypassed" Nginx and sent data directly to Tomcat in this
case.

After solving this issue I ran into 3 o 4 problems maybe, but that
does not matter anymore. Right now Xforms seem to be arriving to OpenMRS,
better said: they at least reach the
XformDataUploadManager.processXform(...) method from Xforms module,
but then I get the following in OpenMRS's log:

ERROR - XformsUtil.reportDataUploadError(615) |2011-01-08
04:13:16,249| null
java.lang.NullPointerException
at org.apache.commons.io.IOUtils.toInputStream(IOUtils.java:612)
at
org.openmrs.module.xforms.download.XformDataUploadManager.processXform(XformDataUploadManager.java:88)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doGet(XformDataUploadServlet.java:79)
at
org.openmrs.module.xforms.web.XformDataUploadServlet.doPost(XformDataUploadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

It refers to line 88 of XformDataUploadManager where we have:

    public static void processXform(String xml, String sessionId,

String enterer, boolean propagateErrors,HttpServletRequest request) throws
Exception{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc =
db.parse(IOUtils.toInputStream(xml,XformConstants.DEFAULT_CHARACTER_ENCODING));
setHeaderValues(doc,sessionId,enterer);

queueForm(XformsUtil.doc2String(doc),propagateErrors,request);
}

I have commons-io-1.4.jar, if that's useful to know.
This is shown in ODKVoice's log after a call is completed:

2011-01-08 04:13:16,209 INFO FormVxmlRenderer:317 - Set outbound
status: id=80; status=COMPLETE
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
Do not know how to handle preloader [patient]
2011-01-08 04:13:16,211 INFO FormVxmlRenderer:760 - Export data path:
/root/odkvoicedata/instances/+50588367336/1294470742015
2011-01-08 04:13:16,212 INFO FormVxmlRenderer:764 - XML path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
Path:
/root/odkvoicedata/instances/+50588367336/1294470742015/1294470742015.xml
2011-01-08 04:13:16,213 INFO FormVxmlRenderer:784 - Queued
InstanceUploaderThread
2011-01-08 04:13:16,214 INFO FormVxmlRenderer:802 - About to upload
instance to
http://localhost:8080/openmrs_devel/moduleServlet/xforms/xformDataUpload
?uname=xxxxxx&pw=xxxxxx
2011-01-08 04:13:16,219 DEBUG SingleClientConnManager:195 - Get
connection for route HttpRoute[{}->http://localhost:8080]
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.connection.timeout': 50000
2011-01-08 04:13:16,220 DEBUG ClientParamsStack:215 -
'http.socket.timeout': 50000
2011-01-08 04:13:16,221 DEBUG RequestAddCookies:131 - CookieSpec
selected: best-match
2011-01-08 04:13:16,222 DEBUG DefaultRequestDirector:445 - Attempt 1
to execute request
2011-01-08 04:13:16,222 DEBUG DefaultClientConnection:244 - Sending
request: POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[EOL]"
2011-01-08 04:13:16,222 DEBUG wire:78 - >> "Host: localhost:8080[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "Connection:
Keep-Alive[EOL]"
2011-01-08 04:13:16,223 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,223 DEBUG headers:248 - >> POST
/openmrs_devel/moduleServlet/xforms/xformDataUpload?uname=xxxxxx&pw=
xxxxxx HTTP/1.1
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL
2011-01-08 04:13:16,223 DEBUG headers:251 - >> Host: localhost:8080
2011-01-08 04:13:16,224 DEBUG headers:251 - >> Connection: Keep-Alive
2011-01-08 04:13:16,224 DEBUG wire:78 - >> "d2d[EOL]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Disposition:
form-data; name="xml_submission_file"; filename="text/xml"[\r][\n]"
2011-01-08 04:13:16,224 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "Content-Transfer-Encoding:
binary[\r][\n]"
2011-01-08 04:13:16,225 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered /><patient.given_name
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name><patient.family_name
openmrs_table="patient_name"
openmrs_attribute="family_name">Prueba</patient.family_name><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id">4</patient.patient_id><patient.given_name_1
openmrs_table="patient_name"
openmrs_attribute="given_name">Juan</patient.given_name_1><patient.family_name_1
openmrs_table="patient_name"
openmrs_attribute="family_name">Rodriguez</patient.family_name_1><encounter.encounter_datetime
openmrs_table="encounter"
openmrs_attribute="encounter_datetime">2011-01-07</encounter.encounter_datetime><encounter.location_id
openmrs_table="encounter"
openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id
openmrs_table="encounter"
openmrs_attribute="provider_id">20</encounter.provider_id><confirmacion_de_identidad
openmrs_concept="6100^confirmacion de identidad^99DCT"
openmrs_datatype="ST">1</confirmacion_de_identidad><confirmacion_dia_de_cumpleanos
openmrs_concept="6101^confirmacion dia de cumpleanos^99DCT"
openmrs_datatype="ST">1</confirmacion_dia_de_cumpleanos><fecha_de_cita
openmrs_concept="6130^fecha de cita^99DCT" openmrs_datatype="DT">2010-03-03</fecha_de_cita><hora_de_cita
openmrs_concept="6129^hora de cita^99DCT" openmrs_datatype="TM"></hora_de_cita><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir diabetes^99DCT"
openmrs_datatype="ST">1</confirmacion_hora_para_definir_diabetes>"

2011-01-08 04:13:16,227 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,227 DEBUG wire:78 - >> "2f[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >> "[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:64 - >>
"--92mV1yLtiBklUVxQhHi0-Oc2ALeAAlTogyfLlzL--[\r][\n]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "0[EOL]"
2011-01-08 04:13:16,228 DEBUG wire:78 - >> "[EOL]"

Any ideas? tips? I am stuck here now.
Thanks in advance.

Pavel Stephan Muñoz
SSI

---------- Forwarded message ----------
From: Daniel Myung dmyung@dimagi.com
Date: Wed, Dec 29, 2010 at 11:31 AM
Subject: Re: [ODK Community] "HTTP/1.1 411 Length Required" when
trying to push a XForm to OpenMRS from ODKVoice via HTTP-POST
To: opendatakit opendatakit@googlegroups.com

Hi all,

ODK along with other OpenROSA submissions transports in chunked
encoding as part of the header, as per the HTTP 1.1 spec.

From what I gather, Nginx out of the box does not support or honor
the
chunked encoding header and fails hard when a content-length header
is
not present in an HTTP POST as ODK submits. The 411 error is the
telltale sign of this error.

I personally ran into this and tried to remedy by using a later
version of nginx (> 0.8.35)
*) Feature: the "chunked_transfer_encoding" directive.

However, I could not get it to work. I even tried a few workarounds
with different combination of proxy buffering and the like.

The remedy I've seen online but haven't tried personally is to use
the
Chunkin Module which requires rebuilding nginx from source:

http://wiki.nginx.org/HttpChunkinModule

Ultimately, this was an issue we had to work around. The current
workaround we use is having all submissions go through apache2 with
mod_proxy. We proxy all posts from port 80 (or 443) on submission,
to
a separate internal port (port 81), but add the mod_proxy
environmental variable SetEnv SendCL 1
(see
http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http)

Assuming you can get the POST working with nginx, there is
potentially
another problem to contend with. On the return 201 message, that too
may cause a 411 error if there is any body in the 201 response. You
may also need to explicitly set a content length on the response even
it if it is zero or non zero.

Hope this helps,
Dan

On Wed, Dec 29, 2010 at 12:15 AM, Pavel Stephan Muñoz minibota@gmail.com wrote:

Hello masters ;),

I have set ODKVoice to upload Xforms to our OpenMRS deployment
after each
call is ended. I did so by editing the UPLOAD_URL string in the
constants/GlobalConstants class. According to this (from the xforms
module)

http://wiki.openmrs.org/display/docs/XForms+Module+External+Applications+Guide

we have two possible URLs to use:

http://server:8080/openmrs/moduleServlet/xforms/xformDataUpload?uname=name&pw=password

http://server:8080/openmrs/module/xforms/xformDataUpload.form?uname=name&pw=password

I have tried both options but we are getting a strange error in our
tomcat's
log. It says: HTTP/1.1 411 Length Required[EOL].
Sounds like ODKVoice is not creating proper HTTP headers for this
transaction; I mean "sounds like", but I doubt it. Other idea I
have about
possible causes: our tomcat is behind a nginx web server...

Can you bring us a light, as you always do? I am pasting the log
here, so
you can check.
Thank you all.

Pavel Stephan Muñoz.

2010-12-28 22:27:02,336 DEBUG DefaultClientConnection:244 - Sending
request:
POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1[EOL]"
2010-12-28 22:27:02,336 DEBUG wire:78 - >> "Transfer-Encoding:
chunked[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Content-Type:
multipart/form-data;
boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Host: ehs.hopto.org
[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "Connection:
Keep-Alive[EOL]"
2010-12-28 22:27:02,342 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,342 DEBUG headers:248 - >> POST

/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

HTTP/1.1
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Transfer-Encoding:
chunked
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Content-Type:
multipart/form-data; boundary=V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf
2010-12-28 22:27:02,342 DEBUG headers:251 - >> Host: ehs.hopto.org
2010-12-28 22:27:02,343 DEBUG headers:251 - >> Connection:
Keep-Alive
2010-12-28 22:27:02,352 DEBUG wire:78 - >> "66c[EOL]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Disposition:
form-data;
name="xml_submission_file"; filename="text/xml"[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >> "Content-Type:
application/octet-stream[\r][\n]"
2010-12-28 22:27:02,353 DEBUG wire:64 - >>
"Content-Transfer-Encoding:
binary[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,354 DEBUG wire:78 - >> "<?xml version='1.0' ?><date_entered
/><patient.family_name
openmrs_table="patient_name" openmrs_attribute="family_name"
/><patient.given_name openmrs_table="patient_name"
openmrs_attribute="given_name" /><patient.patient_id
openmrs_table="patient"
openmrs_attribute="patient_id"
/><encounter.encounter_datetime
openmrs_table="encounter" openmrs_attribute="encounter_datetime"
/><encounter.location_id openmrs_table="encounter"

openmrs_attribute="location_id">1</encounter.location_id><encounter.provider_id

openmrs_table="encounter"

openmrs_attribute="provider_id">1</encounter.provider_id><obs

openmrs_concept="1238^MEDICAL RECORD OBSERVATIONS^99DCT"
openmrs_datatype="ZZ"><confirmacion_hora_para_definir_diabetes
openmrs_concept="6102^confirmacion hora para definir
diabetes^99DCT"
openmrs_datatype="NM">2</confirmacion_hora_para_definir_diabetes>"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:78 - >> "2b[EOL]"
2010-12-28 22:27:02,356 DEBUG wire:64 - >> "[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:64 - >>
"--V4Nt2YzJfsuLt20b3zCWi3TuqUrBH6bXqMf--[\r][\n]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "0[EOL]"
2010-12-28 22:27:02,357 DEBUG wire:78 - >> "[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "HTTP/1.1 411 Length
Required[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Server:
nginx/0.7.65[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Date: Wed, 29 Dec 2010
01:27:13
GMT[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Type:
text/html[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Content-Length:
181[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "Connection: close[EOL]"
2010-12-28 22:27:02,358 DEBUG wire:78 - << "[EOL]"
2010-12-28 22:27:02,359 DEBUG DefaultClientConnection:229 -
Receiving
response: HTTP/1.1 411 Length Required
2010-12-28 22:27:02,359 DEBUG headers:232 - << HTTP/1.1 411 Length
Required
2010-12-28 22:27:02,359 DEBUG headers:235 - << Server: nginx/0.7.65
2010-12-28 22:27:02,359 DEBUG headers:235 - << Date: Wed, 29 Dec
2010
01:27:13 GMT
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Type:
text/html
2010-12-28 22:27:02,359 DEBUG headers:235 - << Content-Length: 181
2010-12-28 22:27:02,359 DEBUG headers:235 - << Connection: close
2010-12-28 22:27:02,362 DEBUG ClientParamsStack:215 -
'http.protocol.handle-redirects': false
2010-12-28 22:27:02,362 ERROR InstanceUploader:148 - Location
header was
absent
2010-12-28 22:27:02,362 WARN FormVxmlRenderer:806 - Instance
upload to
server at

http://ehs.hopto.org/openmrs_devel/moduleServlet/xforms/xformDataUpload.form?uname=pmunoz&pw=xxxxxxxx

failed. Will try again in 60000 ms.

--
Pavel Stephan Muñoz

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--


Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others,
we shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others,
we shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.

--
Pavel Stephan Muñoz

--
Pavel Stephan Muñoz

--
If we keep uppermost in our minds the unkind and unjust acts of others, we
shall find it impossible to love them as Christ has loved us; but if our
thoughts dwell upon the wondrous love and pity of Christ for us, the same
spirit will flow out to others.