7

I'm using Flutter web_socket_channel package to communicate with server. The class WebSocketChannel doesn't take a header parameter.

factory WebSocketChannel.connect(Uri uri, {Iterable<String>? protocols}) =>
      platform.connect(uri, protocols: protocols);

When using IOWebSocketChannel to pass header, I'm getting Unsupported operation: Platform._version in web like given here. It is working fine in Android and iOS.

Haseeb Pavaratty
  • 554
  • 3
  • 17

1 Answers1

0

The concise answer is: No because only the path in your URI and protocol field can be set up.

Longer answer: In the pure JS WebSocket API, there is no method to specify extra headers for the browser to send.

You can specify only

GET query(was://mysockets.com/path)

and header protocol called Sec-WebSocket-Protocol

Conclusion: If you can't achieve such functionality in the native code then this functionality is unavailable for your flutter web app

Happy coding

powerman23rus
  • 1,297
  • 1
  • 9
  • 17