How to connect wss in flutter web?

Viewed 173

I try to connect a socket-io with flutter. Before, our server-side developer give me an URL without SSL-Certificate and everything is worked. But now, our server has SSL-Certificate, I can't connect to that socket-io. This is my code to connect:

Socket socket = io(
  'wss://server-address',
   OptionBuilder()
        .setTransports(['websocket'])
        .disableAutoConnect()
        .build());
socket.connect();
socket.onConnect((_) {
  print('socket connect');
});
socket.onConnectError((data) => print('socket error = ' + data.toString()));

I get this error:

socket error = {msg: websocket error, desc: null, type: TransportError}

I try to deploy my web application on a secure host like firebase but still have problems. In inspect of firefox, I also see this error:

Firefox cant establish a connection to the server

How to fix this problem? How to connect to secure socket-io address in flutter web?

0 Answers
Related