WSS not working

My web app uses websockets to communicate between frontend SPA and Micronaut backend. Everything has been working fine but now I am trying to move everything to use TLS.

I deployed a certificate on the backend and if I understand the docs correctly, I should be able to just use wss:// from the frontend to connect and everything should work fine.

However, the connection fails without any useful error in the browser. Firefox gives me a NS_ERROR_NET_RESET. When I try to connect via npx wscat -c wss://api.shitchat.app:80/ws/socket I get error: write EPROTO 40B89CFD01000000:error:0A0000C6:SSL routines:tls_get_more_records:packet length too long:ssl/record/methods/tls_common.c:663: which the Internet seems to think indicates that I am connecting to http via https. When I use ws:// everything works.

The TLS should terminate at the fly proxy without me doing anything, correct?

The section about ports from my .toml incase it helps:

[[services]]
internal_port = 8080
protocol = "tcp"
    [services.concurrency]
    hard_limit = 100
    soft_limit = 90

    [[services.ports]]
    handlers = ["http"]
    port = 80

    [[services.ports]]
    handlers = ["tls", "http"]
    port = "443"

    [[services.tcp_checks]]
    interval = 10000
    timeout = 2000

Only on port 443, though.

(You were using port 80 in your wscat invocation.)

I do get the expected TLS v1.3 websocket connection when replacing :80 with :443 in that URL (and testing via curl).

You can just remove the topmost services.ports block, for port 80, if you want to enforce TLS-only, :cactus:.

1 Like

Thank you! I just noticed this and removed the port from the address and now this is working as expected. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.