I'm having issues with a connection coming from an Android app
connecting both trough an nginx proxy, but also using some REST testing tools: nginx error log: 2013/12/12 23:23:17 [error] 701#0: *49 upstream prematurely closed connection while reading response header from upstream, client: XX.XX.XX.XX, server: app01.mydomain.com, request: "POST /app-api/v1/auth/login HTTP/1.1", upstream: "http://127.0.0.1:8080/app-api/v1/auth/login", host: "app01.mydomain.com:80" (END) ZnZincSeasideAdapter log: 2013-12-12 23:23:17 897330 D Executing request/response loop 2013-12-12 23:23:17 897330 I Read a ZnRequest(POST /app-api/v1/auth/login) 2013-12-12 23:23:17 897330 T POST /app-api/v1/auth/login 200 114B 42ms 2013-12-12 23:23:17 897330 D ConnectionClosed: Cannot write data while writing response 2013-12-12 23:23:17 897330 D Closing stream I'm using Basic HTTP Auth in each request. But what's weird is that with curl it works perfectly fine. Again, I think this is not strictly Zinc related, but it doesn't work connecting directly to the Zinc server either: 2013-12-13 00:17:02 939035 D Executing request/response loop 2013-12-13 00:17:02 939035 I Read a ZnRequest(POST /app-api/v1/auth/login) 2013-12-13 00:17:02 939035 T POST /app-api/v1/auth/login 200 114B 12ms 2013-12-13 00:17:02 939035 D ConnectionClosed: Cannot write data while writing response 2013-12-13 00:17:02 939035 D Closing stream I don't know if this has to do with the wireless provider doing some proxying behind the wall (which they do), but given the fact that if I try using some REST testing tools from my computer and they also fail, I think it has to do with something else. At nginx I'm forwarding the Authorization header to the Zinc Server: proxy_set_header Authorization $http_authorization; proxy_pass_header Authorization; Is there a way I can log the complete request headers at the Zinc side, and if possible also at nginx? Regards, Esteban A. Maringolo |
Good news, bad news. :)
I decided to test using another great tool bundled with Pharo itself: ZnClient. "Going through nginx" ZnClient new url: 'http://myserver.com/app-api/v1/auth/login'; setBasicAuthenticationUsername: '24603458' password: '1234'; logToTranscript; post; response. And... as expected... it works! The same if connect directly to Zinc (:8080). So there is something wrong in the rest of the tools around... or I really don't know. But the HTTP client library we're using at the Android (Java) side is one of the most used (http://loopj.com/android-async-http/), but also fails with org.apache.http client. So... it's not a matter of client. I just need to understand the reason for the "Closed Connection". Esteban A. Maringolo 2013/12/12 Esteban A. Maringolo <[hidden email]>: > I'm having issues with a connection coming from an Android app > connecting both trough an nginx proxy, but also using some REST > testing tools: > > nginx error log: > 2013/12/12 23:23:17 [error] 701#0: *49 upstream prematurely closed > connection while reading response header from upstream, client: > XX.XX.XX.XX, server: app01.mydomain.com, request: "POST > /app-api/v1/auth/login HTTP/1.1", upstream: > "http://127.0.0.1:8080/app-api/v1/auth/login", host: > "app01.mydomain.com:80" > (END) > > ZnZincSeasideAdapter log: > 2013-12-12 23:23:17 897330 D Executing request/response loop > 2013-12-12 23:23:17 897330 I Read a ZnRequest(POST /app-api/v1/auth/login) > 2013-12-12 23:23:17 897330 T POST /app-api/v1/auth/login 200 114B 42ms > 2013-12-12 23:23:17 897330 D ConnectionClosed: Cannot write data while > writing response > 2013-12-12 23:23:17 897330 D Closing stream > > I'm using Basic HTTP Auth in each request. > > But what's weird is that with curl it works perfectly fine. > > Again, I think this is not strictly Zinc related, but it doesn't work > connecting directly to the Zinc server either: > > 2013-12-13 00:17:02 939035 D Executing request/response loop > 2013-12-13 00:17:02 939035 I Read a ZnRequest(POST /app-api/v1/auth/login) > 2013-12-13 00:17:02 939035 T POST /app-api/v1/auth/login 200 114B 12ms > 2013-12-13 00:17:02 939035 D ConnectionClosed: Cannot write data while > writing response > 2013-12-13 00:17:02 939035 D Closing stream > > I don't know if this has to do with the wireless provider doing some > proxying behind the wall (which they do), but given the fact that if I > try using some REST testing tools from my computer and they also fail, > I think it has to do with something else. > > At nginx I'm forwarding the Authorization header to the Zinc Server: > > proxy_set_header Authorization $http_authorization; > proxy_pass_header Authorization; > > Is there a way I can log the complete request headers at the Zinc > side, and if possible also at nginx? > > Regards, > > > Esteban A. Maringolo |
Answering myself again (I know...).
There is some issue in how the Basic Authentication is handled in certain Android devices [1], which by chance (fortunately) is the same I use to develop with, so I had to change the way the header was set in the request, which basically I setup manually [2] So, only good news. The server is up and running. In fact it is the second server, I created a second Droplet at Digital Ocean because the first had Ubuntu 12.04 LTS and I wanted a newer release to have the newer version of nignx as well. So Ubuntu 13.10 32bit it was. The second time everything went smoother and faster. I'm thinking about setting up a Docker [3] container for Pharo, and then use it in Digital Ocean as well [4]. It was a long day, but worth it. Best regards, Esteban A. Maringolo [1] https://github.com/loopj/android-async-http/issues/262 [2] http://stackoverflow.com/a/20558752/644918 [3] http://www.docker.io (anybody using it?) [4] https://www.digitalocean.com/community/articles/how-to-use-the-digitalocean-docker-application 2013/12/12 Esteban A. Maringolo <[hidden email]>: > Good news, bad news. :) > > I decided to test using another great tool bundled with Pharo itself: ZnClient. > > > "Going through nginx" > ZnClient new > url: 'http://myserver.com/app-api/v1/auth/login'; > setBasicAuthenticationUsername: '24603458' password: '1234'; > logToTranscript; > post; > response. > > And... as expected... it works! > > The same if connect directly to Zinc (:8080). > > So there is something wrong in the rest of the tools around... or I > really don't know. > > But the HTTP client library we're using at the Android (Java) side is > one of the most used (http://loopj.com/android-async-http/), but also > fails with org.apache.http client. So... it's not a matter of client. > > I just need to understand the reason for the "Closed Connection". > > > > > Esteban A. Maringolo > > > 2013/12/12 Esteban A. Maringolo <[hidden email]>: >> I'm having issues with a connection coming from an Android app >> connecting both trough an nginx proxy, but also using some REST >> testing tools: >> >> nginx error log: >> 2013/12/12 23:23:17 [error] 701#0: *49 upstream prematurely closed >> connection while reading response header from upstream, client: >> XX.XX.XX.XX, server: app01.mydomain.com, request: "POST >> /app-api/v1/auth/login HTTP/1.1", upstream: >> "http://127.0.0.1:8080/app-api/v1/auth/login", host: >> "app01.mydomain.com:80" >> (END) >> >> ZnZincSeasideAdapter log: >> 2013-12-12 23:23:17 897330 D Executing request/response loop >> 2013-12-12 23:23:17 897330 I Read a ZnRequest(POST /app-api/v1/auth/login) >> 2013-12-12 23:23:17 897330 T POST /app-api/v1/auth/login 200 114B 42ms >> 2013-12-12 23:23:17 897330 D ConnectionClosed: Cannot write data while >> writing response >> 2013-12-12 23:23:17 897330 D Closing stream >> >> I'm using Basic HTTP Auth in each request. >> >> But what's weird is that with curl it works perfectly fine. >> >> Again, I think this is not strictly Zinc related, but it doesn't work >> connecting directly to the Zinc server either: >> >> 2013-12-13 00:17:02 939035 D Executing request/response loop >> 2013-12-13 00:17:02 939035 I Read a ZnRequest(POST /app-api/v1/auth/login) >> 2013-12-13 00:17:02 939035 T POST /app-api/v1/auth/login 200 114B 12ms >> 2013-12-13 00:17:02 939035 D ConnectionClosed: Cannot write data while >> writing response >> 2013-12-13 00:17:02 939035 D Closing stream >> >> I don't know if this has to do with the wireless provider doing some >> proxying behind the wall (which they do), but given the fact that if I >> try using some REST testing tools from my computer and they also fail, >> I think it has to do with something else. >> >> At nginx I'm forwarding the Authorization header to the Zinc Server: >> >> proxy_set_header Authorization $http_authorization; >> proxy_pass_header Authorization; >> >> Is there a way I can log the complete request headers at the Zinc >> side, and if possible also at nginx? >> >> Regards, >> >> >> Esteban A. Maringolo |
In reply to this post by Esteban A. Maringolo
esteban
it would be really great if you could extract from your experience a kind of blog, book chapter whatever to share it with other developers around the world. Stef On Dec 13, 2013, at 1:36 AM, Esteban A. Maringolo <[hidden email]> wrote: > I'm having issues with a connection coming from an Android app > connecting both trough an nginx proxy, but also using some REST > testing tools: > > nginx error log: > 2013/12/12 23:23:17 [error] 701#0: *49 upstream prematurely closed > connection while reading response header from upstream, client: > XX.XX.XX.XX, server: app01.mydomain.com, request: "POST > /app-api/v1/auth/login HTTP/1.1", upstream: > "http://127.0.0.1:8080/app-api/v1/auth/login", host: > "app01.mydomain.com:80" > (END) > > ZnZincSeasideAdapter log: > 2013-12-12 23:23:17 897330 D Executing request/response loop > 2013-12-12 23:23:17 897330 I Read a ZnRequest(POST /app-api/v1/auth/login) > 2013-12-12 23:23:17 897330 T POST /app-api/v1/auth/login 200 114B 42ms > 2013-12-12 23:23:17 897330 D ConnectionClosed: Cannot write data while > writing response > 2013-12-12 23:23:17 897330 D Closing stream > > I'm using Basic HTTP Auth in each request. > > But what's weird is that with curl it works perfectly fine. > > Again, I think this is not strictly Zinc related, but it doesn't work > connecting directly to the Zinc server either: > > 2013-12-13 00:17:02 939035 D Executing request/response loop > 2013-12-13 00:17:02 939035 I Read a ZnRequest(POST /app-api/v1/auth/login) > 2013-12-13 00:17:02 939035 T POST /app-api/v1/auth/login 200 114B 12ms > 2013-12-13 00:17:02 939035 D ConnectionClosed: Cannot write data while > writing response > 2013-12-13 00:17:02 939035 D Closing stream > > I don't know if this has to do with the wireless provider doing some > proxying behind the wall (which they do), but given the fact that if I > try using some REST testing tools from my computer and they also fail, > I think it has to do with something else. > > At nginx I'm forwarding the Authorization header to the Zinc Server: > > proxy_set_header Authorization $http_authorization; > proxy_pass_header Authorization; > > Is there a way I can log the complete request headers at the Zinc > side, and if possible also at nginx? > > Regards, > > > Esteban A. Maringolo > |
Stef,
About what exactly? About the server setup or the connection issues? I plan to write down everything once this goes live and, most importantly, succeeds. :) Regards! 2013/12/13 Stéphane Ducasse <[hidden email]>: > esteban > > it would be really great if you could extract from your experience a kind of > blog, book chapter whatever to share it with other developers around the world. |
On Dec 13, 2013, at 7:15 PM, Esteban A. Maringolo <[hidden email]> wrote: > Stef, > > About what exactly? About the server setup or the connection issues? things :) > I plan to write down everything once this goes live and, most > importantly, succeeds. :) Excellent! > > Regards! > > 2013/12/13 Stéphane Ducasse <[hidden email]>: >> esteban >> >> it would be really great if you could extract from your experience a kind of >> blog, book chapter whatever to share it with other developers around the world. > |
Free forum by Nabble | Edit this page |