Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSS error: Connection to https://... was not upgraded to websocket #16

Open
web75018 opened this issue Nov 10, 2021 · 0 comments
Open

Comments

@web75018
Copy link

web75018 commented Nov 10, 2021

Hi there,
Thanks for the package.

How can is add ssl support?
final String url = 'wss://{my_domain_name_.com}:443/'; => ???
var socket = await Socket.connect(url, listener: new MyListener());
socket.on('rand', (name, data, ack) {
print('got message $data from event $name');
ack(name, 'No error', 'Hi there buddy');
})

Im getting this error:
E/flutter (10461): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: WebSocketException: Connection to 'https://{my_domain_name_.com}/#' was not upgraded to websocket
E/flutter (10461): #0 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1017:41)
E/flutter (10461): #1 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter (10461): #2 IoSocketPlatform.webSocket (package:socketcluster_client/src/socket_platform_io.dart:10:51)
E/flutter (10461): #3 Socket.connect (package:socketcluster_client/src/socket.dart:48:47)
E/flutter (10461): #4 main (package:socketcluster/main.dart:39:29)
E/flutter (10461): #5 _runMainZoned.. (dart:ui/hooks.dart:145:25)
E/flutter (10461): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter (10461): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter (10461): #8 _runZoned (dart:async/zone.dart:1863:10)
E/flutter (10461): #9 runZonedGuarded (dart:async/zone.dart:1851:12)
E/flutter (10461): #10 _runMainZoned. (dart:ui/hooks.dart:141:5)
E/flutter (10461): #11 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:283:19)
E/flutter (10461): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

NGINX config:
server{
server_name sub.domain.com;

location / {
    proxy_pass http://localhost:3000; #Nodejs server.
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header HOST $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass_request_headers on;
    #proxy_http_version 1.1;
    #proxy_set_header Upgrade $http_upgrade;
    #proxy_set_header Connection 'upgrade';
    #proxy_set_header Host $host;
    #proxy_cache_bypass $http_upgrade;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/sub.domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sub.domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server{
if ($host = sub.domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot

server_name sub.domain.com;
listen 80;
return 404; # managed by Certbot
}

@web75018 web75018 changed the title WS with SSL connect WSS error: Connection to https://... was not upgraded to websocket Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant