Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Holoviz Panel application refusing websocket connection from Origin when deploying in AWS EKS

$
0
0

I have a holoviz panel application file called app.py. Here is the Dockerfile for the app:

#!/bin/bashFROM python:3.11-slimWORKDIR /codeCOPY ./requirements.txt /code/requirements.txtRUN pip install --no-cache-dir --upgrade -r /code/requirements.txtCOPY . .EXPOSE 8080CMD ["panel", "serve", "--port", "8080", "app.py", "--address", "0.0.0.0", "--allow-websocket-origin", "*"]

It builds and runs on local perfectly.

Here is my web-app-deployment.yaml file to deploy in Kubernetes cluster (EKS):

apiVersion: apps/v1kind: Deploymentmetadata:  name: charlie-web-app-deploymentspec:  replicas: 1  selector:    matchLabels:      app: charlie-web-app  template:    metadata:      labels:        app: charlie-web-app    spec:      containers:      - name: charlie-web-app        image: <account-id>.dkr.ecr.<region-code>.amazonaws.com/<cluster-name>:charlie        imagePullPolicy: Always        ports:        - containerPort: 8080        env:        - name: OLLAMA_API_ENDPOINT          value: "http://ollama:11434"        - name: BOKEH_ALLOW_WS_ORIGIN          value: "0.0.0.0"        command: ["panel"]        args: ["serve", "--port", "8080", "app.py", "--address", "0.0.0.0", "--allow-websocket-origin", "*"]---apiVersion: v1kind: Servicemetadata:  name: charlie-web-app-servicespec:  type: ClusterIP  ports:  - port: 80    targetPort: 8080  selector:    app: charlie-web-app

The deployment gets done with no error. But, when I port-forward the deployment to test on local, the app UI loads partially (only shows the title of the app) and does not load the rest of the UI. When I inspect element, I can see the following errors:

enter image description here

Here are the console errors expanded:

enter image description hereenter image description here

When I do kubectl logs <pod-name>, I see the following:

2024-05-01 12:59:35,445 Starting Bokeh server version 3.4.1 (running on Tornado 6.4)2024-05-01 12:59:35,446 Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly2024-05-01 12:59:35,446 User authentication hooks NOT provided (default user enabled)2024-05-01 12:59:35,448 Bokeh app running at: http://0.0.0.0:8080/app2024-05-01 12:59:35,449 Starting Bokeh server with process id: 12024-05-01 12:59:41,969 Refusing websocket connection from Origin 'http://localhost:60373';                       use --allow-websocket-origin=localhost:60373 or set BOKEH_ALLOW_WS_ORIGIN=localhost:60373 to permit this; currently we allow origins {'0.0.0.0'}2024-05-01 12:59:41,969 403 GET /app/ws (127.0.0.1) 0.53ms2024-05-01 13:00:06,655 Refusing websocket connection from Origin 'http://localhost:60373';                       use --allow-websocket-origin=localhost:60373 or set BOKEH_ALLOW_WS_ORIGIN=localhost:60373 to permit this; currently we allow origins {'0.0.0.0'}2024-05-01 13:00:06,656 403 GET /app/ws (127.0.0.1) 0.57ms

Upon googling and researching about the web socket error, it appears that it's usually related to the allow-websocket-origin not being present, but I have it in my yaml file and Dockerfile. I have also added the BOKEH_ALLOW_WS_ORIGIN as an environment variable in the yaml file as suggested in the kubectl logs. So, what's going on? I have tried changing the port in the Dockerfile and the yaml file to 8090, made no difference. I have tried the solution mentioned here, no difference. I have tried different versions of the panel library, no difference. What else could I try or check?


Viewing all articles
Browse latest Browse all 12111

Trending Articles