Websockets deployed on nomad fails to receive a message and disconnects

I have deployed a fastapi container via nomad which has websocket.
When sending a message to the websocket endpoint,
I get the error - 1002 Protocol Error: Endpoint terminated the connection due to a protocol error. on postman. The same works when hosted normally(using simple nginx reverse proxy and running the api in screen session).

Below is the nomad jobfile that I am using.

job "ws-test" {
	datacenters = ["lightsail-testing"]

	group "ws-test" {
		network {
			port "http" {
				to = 8000
			}
		}

		task "ws-test" {
			driver = "docker"

			config {
				image = "saujanya01/local-ws"
				ports = ["http"]
			}

			resources {
				cpu = 500
				memory = 2048
			}

			service {
				name = "ws-test"

				tags = [
					"ws-test",
					"traefik.enable=true",
					"traefik.http.routers.ws-http.rule=Host(`ws.example.com`)",
                    "traefik.http.routers.ws-http.entrypoints=http",
                    "traefik.http.routers.ws.rule=Host(`ws.example.com`)",
                    "traefik.http.routers.ws.entrypoints=https",
                    "traefik.http.routers.ws.tls=true",
                    "traefik.http.routers.ws.tls.certresolver=letsencrypt",
                    "traefik.http.routers.ws.tls.domains[0].main=*.example.com",
					"traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https",
					"traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true",
					"traefik.http.middlewares.test-redirectscheme.redirectscheme.port=https"
				]

port = "http"

				provider = "nomad"
			}
		}
	}
}

I am using traefik for redirection.
Code for the websocket - GitHub - saujanya01/local_ws_sample

What am i getting wrong here?

Traefik version
Version:      2.10.4
Codename:     saintmarcelin
Go version:   go1.20.6
Built:        2023-07-24T16:29:02Z
OS/Arch:      linux/amd64