dart-lang / web_socket_channel

StreamChannel wrappers for WebSockets.
https://pub.dev/packages/web_socket_channel
BSD 3-Clause "New" or "Revised" License
421 stars 109 forks source link

In web_socket_channel connection can't set header for authentication #200

Open anjojy opened 3 years ago

anjojy commented 3 years ago

can't pass authentication cookie when create `channel

final _channel = WebSocketChannel.connect(Uri.parse('URL'));

lupiter-dev commented 3 years ago

As stated in this answer, apparently the use of authorization HTTP headers is not the intended way to perform authentication in the web socket protocol. Suggested alternatives are:

itsji10dra commented 8 months ago

Use IOWebSocketChannel instead of WebSocketChannel.connect

_channel = IOWebSocketChannel.connect(
        Uri.parse(Constants.connectionUrl),
        headers: Headers.getHeaderParameters(),
      );
beheobong commented 7 months ago

try this: https://stackoverflow.com/a/41521871 . It is good for you