Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

hypercorn - I can't connect to websockets from my domain. How can I resolve this?

I am unable to connect to any websockets from clients at my webapp's domain. I am serving the web app using Hypercorn.

I know the websocket for my app is working because I can connect to it from another domain:

// From a client at another domain, this works!

    let ws = new WebSocket("ws://mysite/endpoint"); 
    ws.onopen = function() {
        alert("Connection established");
    };

I can't connect to any websockets from my domain. The example below is a test socket:

// Doesn't work when this is run at my domain.

    let ws = new WebSocket("wss://echo.websocket.org"); 
    ws.onopen = function() {
        alert("Connection established");
    };

Oddly enough, the (server side) debugger output on my site's websocket shows that connections from my domain are being made. However, I am unable to receive any data from the client. The client does not indicate any connection has been made.

I've never run into this before. But, my guess is there's some server config piece that I'm missing. Any suggestions are much appreciated.

question from:https://stackoverflow.com/questions/65866500/i-cant-connect-to-websockets-from-my-domain-how-can-i-resolve-this

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...