Proxy error the proxy server received an invalid response from an upstream server

Testing a datasource in Administration Console fails with Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request POST /ibmcognos/bi/v1/disp. Reason: Error reading from remote server

Problem

Testing a datasource in Administration Console fails with

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /ibmcognos/bi/v1/disp.

Reason: Error reading from remote server

image-20190528101100-1

Symptom

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /ibmcognos/bi/v1/disp.

Reason: Error reading from remote server

Cause

Testing the datasource takes longer than the defined timeout on Apache Webserver.

Environment

IBM Cognos Analytics with Gateway installation

Apache 2.2 or 2.4 as Webserver

Resolving The Problem

In the Apache Webserver configuration (ie. cognos.conf) increase or set the TimeOut parameter.

By default the TimeOut is set to 60 seconds.

Example:

KeepAliveTimeout 5
TimeOut 120

A restart of Apache Webserver is required after saving the changed configuration.

For more information refer to the Apache Webserver documentation: https://httpd.apache.org/docs/2.4/en/mod/core.html#timeout

Related Information

Document Location

Worldwide

[{«Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Product»:{«code»:»SSTSF6″,»label»:»IBM Cognos Analytics»},»Component»:»»,»Platform»:[{«code»:»PF025″,»label»:»Platform Independent»}],»Version»:»»,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}}]

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Closed

panovitch opened this issue

Jan 25, 2018

· 22 comments

Comments

@panovitch

Hi there! Was wondering if you have some insight on the following problem:

Long story short

We are running an aiohttp app behind an Apache proxy. Around 20% of requests to the app cause Apache to return 502 Proxy Error.

These happen with requests to all endpoints of the server, and there seems to be no pattern to errors of any kind. The proxy error is returned immediately upon request.
Other servers/apps (built on other frameworks, for example, tornado) run behind the same Apache proxy and do not show the same behavior.

The example of Apache logs:

[Tue Jan 23 12:38:51.050529 2018] [proxy_http:error] [pid <pid>:tid <tid>] (20014)Internal error (specific information not available): [client <IP address>] AH01102: error reading status line from remote server <hostname>

Full error response example:

HTTP/1.1 502 Proxy Error
Connection: Keep-Alive
Content-Length: 502
Content-Type: text/html; charset=iso-8859-1
Date: Tue, 23 Jan 2018 13:47:29 GMT
Keep-Alive: timeout=15, max=100
Server: Apache/2.4.18 (Ubuntu)

502 Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request.
Reason: Error reading from remote server

Your environment

aiohttp==2.3.9
python 3.6.3
Apache 2.4.18

@samuelcolvin

Do you see anything in the logs from aiohttp?

How are you running aiohttp? With gunicorn or directly?

I guess debug level logs from aiohttp (and gunicorn if it’s running) would help.

Also how is the aiohttp server addressed by apache (by an ip or a hostname)? I’ve had similar issues that turned out to be DNS problems which were fixed by using static IPs.

@panovitch

Hi @samuelcolvin,
We are running aiohttp directly.
The Apache addresses the server by a hostname, but I doubt that issue is DNS-related, since other apps also run on the same host and dont have any problems.
There are no records in aiohttp logs for the problematic requests at all.

@asvetlov

@aalhour

Hello @asvetlov,

Do you have any recommendation for us to validate the source of the issue? How can we help you guys resolve this problem?

@asvetlov

@asvetlov

Sorry, after digging in I did not found expected bug.
Cannot reproduce locally.

aiohttp error log is required (with DEBUG level enabled) for getting more information about the problem.

@mariuszluciow

I’m having something similar, running aiohttp behind zuul proxy. After several good responses, and a while of doing nothing, server starts responding with incorrect response, which starts with rnTP/1.1 200 OK instead of HTTP/1.1 200 OK

@asvetlov

  1. Not sure if you have the same problem.
  2. I need reliable way for reproducing the error — otherwise a change for fix is very low. Python test would be awesome.

@panovitch

Hi @asvetlov,

We tried to check the aiohttp debug logs, that’s how we tried to do it, and how we are running the app:

def setup_loggers():
    stream_handler = logging.StreamHandler(stream=sys.stderr) 
    _stream_handler.setLevel(logging.DEBUG)

    loggers = [getLogger('aiohttp.internal'), getLogger('aiohttp.server')]
    for logger in loggers:
        logger.setLevel(logging.DEBUG)
        logger.addHandler(_stream_handler)

def run_app():
    """
    Application runner function.
    """
    setup_loggers()
    app = create_app()
    host = server_option("host")
    port = int(server_option("port"))

    web.run_app(
        app=app, host=host, port=port, access_log=make_logger(is_development=True),
        access_log_format=access_log_format)

We ran the app with this configuration, but were unable to see anything related to the problematic requests — they do not even register in the access log.

I’m posting the Apache config below, hope it might help you reproduce it.

Apache Configuration

apache2.conf

Default config. Nothing special here.

sites-enabled

ServerName mine.localhost.com
ProxyRequests Off

<Location /aiohttp_app/>
ProxyPass http://localhost:8137/ retry=0
ProxyPassReverse http://localhost:8137/
</Location>

Apache Error Logs

[Fri Feb 02 16:05:41.865610 2018] [proxy_http:error] [pid 6146:tid 140638813112064] (20014)Internal error (specific information not available): [client 127.0.0.1:39048] AH01102: error reading status line from remote server localhost:8137
[Fri Feb 02 16:05:41.865899 2018] [proxy:error] [pid 6146:tid 140638813112064] [client 127.0.0.1:39048] AH00898: Error reading from remote server returned by /aiohttp_app/ping
[Fri Feb 02 16:05:41.875609 2018] [proxy_http:error] [pid 6147:tid 140638787933952] (20014)Internal error (specific information not available): [client 127.0.0.1:39050] AH01102: error reading status line from remote server localhost:8137
[Fri Feb 02 16:05:41.875797 2018] [proxy:error] [pid 6147:tid 140638787933952] [client 127.0.0.1:39050] AH00898: Error reading from remote server returned by /aiohttp_app/ping

@asvetlov

Errors are stored in logger named aiohttp.server.
I suggest calling logging.basicConfig(level=logging.DEBUG) to see all logs.

@mariuszluciow

I spend few hours to produce some small replicable example with no luck. If anything changes I will let you know, thanks anyway!

@panovitch

Hi @asvetlov, running the app with logging.basicConfig(level=logging.DEBUG) also doesn’t show anything. To help reproduce the problem, I’ve created this: https://github.com/panovitch/test_aiohttp_502. The repo contains a sample apache config (main config apache.conf, which is not different from the default one AFAIK, and a site config for sites-enabled), a way to test for error, and an app (a copy of the example app really). Please note that error occurs pretty randomly so give the test some time to run.

@panovitch

Hi everyone,

We eventually managed to solve the problem by adding this to our apache proxy config: disablereuse=on -hope this would be useful!

@pfreixes

@panovitch do you have the chance to test if the error is reproducible with Aiohttp 3.x?

Regarding the disablereuse=on you are forcing to open a TCP connection at each time. is this stack running in local or are separated pieces within a network?

@lordmauve

I am seeing this with aiohttp==3.1.3 and Apache 2.4.10.

@rcupic

Hi everyone,

We eventually managed to solve the problem by adding this to our apache proxy config: disablereuse=on -hope this would be useful!

Hello,
Thank you for letting us know your solution. My question is if there is any downgrade in performance with this setup? I have something like 20-30 requests per minute. This setting sounds like disabling pooled connections which means that every of this 20-30 requests will open new connection for itself even if they are from a same client.
@panovitch

@guillaume-fr

Running into similar issue with aiohttp + gunicorn + apache2.
The same service was running fine on another Python stack + apache2.

(32)Broken pipe: [client 192.168.8.1:44745] AH01084: pass request body failed to [::1]:80 (localhost)

In my environment, I’m not allowed to change disablereuse. The admin is suspecting an issue with keep-alive/persistent connections.

@asvetlov

Apache uses multithreaded/multiprocessed workers to process http requests.
What is the point of deployment aiohttp behind this?
The concurrency level is limited by Apache, and the number is small.
In contrast, nginx or haproxy use asynchronous/nonblocking model, they fit with aiohttp pretty well.

Sorry, I’ve not motivated to support aiohttp+apache combination. If somebody wants to provide a pull request — you are welcome.
Since it did not happen for 2 years yet, I’m closing the issue.

@webknjaz

Apache uses multithreaded/multiprocessed workers to process http requests.

FTR this is not entirely true. You can configure it the way nginx works.

@guillaume-fr

I don’t have control over our infrastructure, Apache2 is used as reverse proxy for all our containers. I spent time learning aiohttp, enjoyed it and thanks a lot your work on this project. On my side I think I’ll have to work with another stack.

Maybe add a note in documentation on Apache not being currently supported as a reverse proxy?

@asvetlov

From my understanding, event worker still uses async mode for inactive connections only. Which may work in some scenarios though.
Anyway, this project is volunteer-driven.
If somebody wants to dig into problems with Apache and make a fix — please do.
Docs update that states that Apache usage is discouraged and not fully supported/tested, use it on own risk, is also acceptable.

guillaume-fr

added a commit
to guillaume-fr/aiohttp
that referenced
this issue

Jan 30, 2020

@guillaume-fr

@Humbedooh

Random question, many moons later: what is your transfer-encoding set to?
I discovered a problem where apache would break with a 502 as well, turns out I had transfer-encoding set to chunked with a non-chunked response. Removing that header solved it for me.

swr85

Starting out
Posts: 10
Joined: Fri Aug 07, 2020 9:09 pm

The proxy server received an invalid response from an upstream server.

Hi,
Running TS-253D with lastest firmware 5.0.0.1891

When starting Virtual station, I get the error message
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request

Reason: Error reading from remote server

I tried to un-install, reboot the NAS and re-install

Still the same issue

Any advise will be helpfull


snorkel

Starting out
Posts: 31
Joined: Fri Jul 10, 2015 8:33 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by snorkel » Mon Jan 10, 2022 4:02 am

I’m getting this same issue on my TS-453D. My error happens just trying to login to the NAS via https://192.168.X.4
I’m on the last official recommended update — like when you login and it says «firmware update available». Can’t specify it while I’m locked out. NAS is at a customer’s house. I am connecting via PPTP VPN. I CAN login to their router, so I don’t think the VPN is the issue.

It sits there and thinks for a while with the following URL in the browser
https://192.168.X.4/redirect.html?count … 5013303335

Then it goes to this after a while
https://192.168.X.4/cgi-bin/QTS.cgi?count=715443
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request
Reason: Error reading from remote server


snorkel

Starting out
Posts: 31
Joined: Fri Jul 10, 2015 8:33 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by snorkel » Mon Jan 10, 2022 7:03 am

I had the customer do a force shutdown and restart. Now the NAS is running and I can login. But something weird is happening if another user is having this same issue. It’s running QTS version 5.0.0.1891

The only extra apps on this unit are idrive for backup and Mcafee. The only thing this unit does is share about 4 folders with 4 computers, so I’m not asking much of it or loading it down with apps. Don’t use Virtual Station


Sorrento2022

New here
Posts: 3
Joined: Mon Jan 10, 2022 1:38 am

Re: The proxy server received an invalid response from an upstream server.

Post

by Sorrento2022 » Mon Jan 10, 2022 8:49 am

Hello
I upgraded to QTS 5.0.0.1891
after about 1/2 days of operation I can no longer log in:
https: //192.168.X.X/redirect.html? count = 0.1465432267051302
The web page prints this wording:
————————————————-
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request
Reason: Error reading from remote server
————————————————-
The same thing on another nas, TS453B, upgrade to QTS 4.5.4.1892 build 20211223
Access also denied via SMB / SSH
This to three customers almost at the same time, but what is going on?


episer

First post
Posts: 1
Joined: Mon Jan 10, 2022 4:33 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by episer » Mon Jan 10, 2022 4:49 pm

Hello everyone!!

Same issue here with 2 QNAP TS-1232XU-RP at the same time. Firmware 4.5.4.1800.
After force rebooting, they are working fine. Now I’ve just upgraded firmware in one of them to version 5.0.0.1891.

Same problem in 2 NAS at the same time is so weird. Anyone can help us, please?



snorkel

Starting out
Posts: 31
Joined: Fri Jul 10, 2015 8:33 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by snorkel » Mon Jan 10, 2022 9:29 pm

Will someone open a ticket with QNAP and reference this post?

I opened a ticket and will report back.


Knightriders

New here
Posts: 3
Joined: Tue Jan 11, 2022 12:46 am

Re: The proxy server received an invalid response from an upstream server.

Post

by Knightriders » Tue Jan 11, 2022 1:09 am

We had the same issue on all of our QNAPs. Scary weekend!!! I just spoke with support and they told me that it’s related to a recent bug caused by malware remover update. Support said it’s a one time issue, problem resolves after first cold boot.eg you need to force shut down and reboot.

Happy monday !!!

See details at https://www.qnap.com/en-us/support/con_ … cation_bar
Solution for NAS Disconnection Caused by Malware Remover Update

A recent Malware Remover service update might cause system disconnection on certain QNAP NAS devices. This issue mainly affects devices where users have enabled auto update in Malware Remover > Settings. We have updated our service policies to fix this issue.

If your NAS stops responding or cannot be accessed after this service update, we recommend following these steps to manually restart the NAS.

Press and hold the power button until the NAS powers off.
Press the power button again to power on the NAS.

Most affected devices should return to normal after a manual restart. If this issue still persists, please contact QNAP Technical Support for further assistance.


egsysad

First post
Posts: 1
Joined: Mon Jan 10, 2022 3:35 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by egsysad » Tue Jan 11, 2022 5:53 pm

With 3 NAS devices for me this resolved itself after a few days — NAS rebooted on its own and resumed normal operations
Seems to have affected mostly devices with insufficient free storage space, under 100 GB.


snorkel

Starting out
Posts: 31
Joined: Fri Jul 10, 2015 8:33 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by snorkel » Tue Jan 11, 2022 11:52 pm

Haven’t heard from QNAP support yet. I hope this problem is a one time thing and caused by what was described above. I just put the NAS in service for this customer and then I have to ask them to do a forced shut down. Pretty lousy. Had I enabled SSH, would I have been able to reboot the NAS from there or was the system unreachable even via SSH?

egsysad wrote: ↑

Tue Jan 11, 2022 5:53 pm


Seems to have affected mostly devices with insufficient free storage space, under 100 GB.

First, 100GB is insufficient free storage space????? Second, I had more than that available when the problem happened.


Sorrento2022

New here
Posts: 3
Joined: Mon Jan 10, 2022 1:38 am

Re: The proxy server received an invalid response from an upstream server.

Post

by Sorrento2022 » Wed Jan 12, 2022 3:21 am

As already written, when the problem occurred, access to ssh is also denied.
Anyway, as suggested in this post by Knightriders Mon Jan 10, 2022 6:09 pm, I have disabled the automatic update of the Malware Remover and its scan. At the moment all the devices are working without any problems.
I have also written to QNAP, and still await an official response


Sorrento2022

New here
Posts: 3
Joined: Mon Jan 10, 2022 1:38 am

Re: The proxy server received an invalid response from an upstream server.

Post

by Sorrento2022 » Wed Jan 12, 2022 3:22 am

In addition to writing to QNAP official support, I have also reported this post for reference.


snorkel

Starting out
Posts: 31
Joined: Fri Jul 10, 2015 8:33 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by snorkel » Wed Jan 12, 2022 9:55 pm

Sorrento2022 wrote: ↑

Wed Jan 12, 2022 3:22 am


In addition to writing to QNAP official support, I have also reported this post for reference.

And I have done the same. Support responded to me and they didn’t even know about this link. I don’t think level 1 support people are even aware of this.
https://www.qnap.com/en-us/support/con_ … cation_bar

The link says «We have updated our service policies to fix this issue.» So, I assume there is no need to disable automatic update of Malware Remover. That’s not a best practice. Then again, neither is losing control of your device.


aDDuBu

Starting out
Posts: 10
Joined: Mon Aug 01, 2016 11:41 pm

Re: The proxy server received an invalid response from an upstream server.

Post

by aDDuBu » Thu Jan 19, 2023 9:12 pm

same issue on my 253a just restarting the NAS


check server related issues

# 1 SSL Configuration

SSL Config with cloudflare if SSL Certificate hosted at sever then SSL Setting in the cloudflare should be strict, not flexible.

flexible if no ssl certificate presented at origin.

#2 Check http header size limit (over 8kb) if it s above cloudflare limits you get this 52o error

tip: also check server logs in origins host.

520 error means

#Temporary Error (502): The server encountered a temporary error and could not complete your request.

#502 Service Temporarily Overloaded

# HTTP Error 502 – Bad Gateway

#Bad Gateway: The proxy server received an invalid response from an upstream /origin server.

1.

#502 Proxy Error

cloudflare timeout error fix 504

to fix this server  timeout 300s (5minutes)

php or any backend application (5 minutes equal or less than server timeout)

database mysql timeout is generally 2 hours.

in nginx

fastcgi as a proxy so we can increase timeout,

clients limits (server to user/browser).

NOTE: these timeout errors temporary during peak.

when limited can’t finish the request in specified time.

if you are shared hosting aske them increase limits or ignore, if problem occurs frequently move to another host or upgrade your plan.

move to vps or cloud hosting.

shared host limits

500X problems related servera unlike 404 not found  301 redirect 200 ok

nginx side proxy readtimeout (Fixed)

500 Internal Server Error

503 Service Unavailable

504 Gateway Timeout

520 Web Server Returned an Unknown Error
The origin server returned an empty, unknown, or unexplained response to Cloudflare.[91]
521 Web Server Is Down
Error 521 occurs when the origin web server refuses connections from Cloudflare. Security solutions at your origin may block legitimate connections from certain Cloudflare IP addresses.
522 Connection Timed Out
Error 522 occurs when Cloudflare times out contacting the origin web server.
523 Origin Is Unreachable
Cloudflare could not reach the origin server; for example, if the DNS records for the origin server are incorrect.
524 A Timeout Occurred
Cloudflare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.
525 SSL Handshake Failed
Cloudflare could not negotiate a SSL/TLS handshake with the origin server.
526 Invalid SSL Certificate
Cloudflare could not validate the SSL certificate on the origin web server. Also used by Cloud Foundry’s gorouter.
527 Railgun Error
Error 527 indicates an interrupted connection between Cloudflare and the origin server’s Railgun server.[92]
530
Error 530 is returned along with a 1xxx error

500 Internal Server Error

A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.

502 Bad Gateway
The server was acting as a gateway or proxy and received an invalid response from the upstream server.
503 Service Unavailable
The server cannot handle the request (because it is overloaded or down for maintenance). Generally, this is a temporary state

504 Gateway Timeout error fic

The server was acting as a gateway or proxy and did not receive a timely response from the upstream server. just increase timeout or mitigaate what caused the long delay.

how to fix 504 gateway nginx timeout error?

504 gateway time out  problem description.

This problem is entirely due to slow IP communication between back-end computers, possibly including the Web server. Only the people who set up the network at the site which hosts the Web server can fix this problem.

client_header_timeout 300;
client_body_timeout 300;
fastcgi_read_timeout 300;
client_max_body_size 32m;
fastcgi_buffers 8 128k;
fastcgi_buffer_size 128k;

if still not solved try below

in case of fastcgi

fastcgi_buffers 8 128k;
fastcgi_buffer_size 256k;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

how nginx causes 504 timeout?

this error appears mainly nginx installed servers. because nginx reduces max_execution_time for .php script.

how to fix 504 error in nginx servers.

simply we need to increase timeout range unfortunately newbies without knowledge can’ do this we need to contact hosting support for increasing limit. some times it’s not worked hosting providers ask permission you to uninstall nginx. if you do this you are out of 504 gateway error. but you get high cpu load on server.

how to increase the timeout limit in ngnix?

/etc/ngnix/ngnix.conf

send_timeout 120;
proxy_read_timeout 120;
proxy_connect_timeout 120;

If they are not there you may add them or create a .conf file in /etc/nginx/conf.d/ folder with those values.
Then restart nginx:
# /etc/init.d/nginx restart

read more about this ngnix .org official.

 to fix 520 521 523 524 gate way time out in cloudflare

how to fix 504 gateway nginx timeout error cloud fare 522 524 error

these errors not by cloudflare it’s by your web server.

fix nginx 502 bad gateway

open /etc/nginx/nginx.conf
add the following lines into http section :

1

2

fastcgi_buffers 8 16k;

fastcgi_buffer_size 32k;

you config should look like this :

1

2

3

4

5

6

7

8

http {

.

.

fastcgi_buffers 8 16k;

fastcgi_buffer_size 32k;

.

.

}

Restart nginx and fastcgi.

How do I fix Cloudflare error 502 bad gateway?

its a temporality problem,

you can read http status codes and their meanings here

resource may help you

http://www.nginxtips.com/502-bad-gateway-using-nginx/

http://www.unixmen.com/how-i-fixed-nginx-502-bad-gateway-error/http://stackoverflow.com/questions/3704626/nginx-502-bad-gateway-error-only-in-firefox

Понравилась статья? Поделить с друзьями:
  • Proxy error host is down i2p
  • Provider named pipes provider error 40 visual studio
  • Protherm jaguar jtv 24 ошибка f08
  • Protherm gepard 23 mtv ошибка f33
  • Protherm f28 ошибка как исправить