At certain point I need to load multiple images, more than a hundred, some are retrieved but many are not loaded. In the chrome console I get the following error:
GET https://api.mydomain.com/images/products/F10014-soporte-caja-2.501.jpg net::ERR_HTTP2_SERVER_REFUSED_STREAM
This images are in a public express folder:
let publicPath = path.join(__dirname, '/public')
console.log(`publicPath ${publicPath}`)
I looked at NodeJS and I couldn't find any errors. I also tried adding annotations in the ingress-nginx
service:
apiVersion: v1
kind: Service
metadata:
annotations:
kubernetes.digitalocean.com/load-balancer-id: "e7f5dc8e-3723-11ec-8d3d-0242ac130003"
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true"
service.beta.kubernetes.io/do-loadbalancer-hostname: "mydomain.com"
labels:
helm.sh/chart: ingress-nginx-4.1.0
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
type: LoadBalancer
externalTrafficPolicy: Local
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
- name: https
port: 443
protocol: TCP
targetPort: https
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/component: controller
My questions are:
ingress-nginx
controller?Let me know if you need information.
In short:
My questions are
- Is the problem in the ingress-nginx controller?
Basically no
- Can this be solved?
Yes
- Should I change my solution and place the files in another place?
It depends :)
First of all, you need to identify where the bug is coming from. You have received ERR_HTTP2_SERVER_REFUSED_STREAM
from this request: https://api.mydomain.com/images/products/F10014-soporte-caja-2.501.jpg
. It looks like you tried to download too much data at once and got this error. How can you fix this error? First of all, you can try downloading data in batches, not all at once. Another solution is to configure your nginx server from which you download pictures. See the documentation:
Sets the maximum number of concurrent HTTP/2 streams in a connection.
Syntax: http2_max_field_size size; Default: http2_max_field_size 4k; Context: http, server
You can here set up bigger value.
You can also set bigger value in the file /etc/nginx/conf.d/custom_proxy_settings.conf
in the line
http2_max_concurrent_streams 256;
The exact name of the file isn't important, it just have to end with .conf and be mounted inside /etc/nginx/conf.d.
Another solution could be disabling HTTP/2 and using HTTP/1.1 protocol, but it may be a security risk.
You have also asked:
Should I change my solution and place the files in another place?
You can, but it shouldn't be necessary.