How to connect websocket with flutter

Future connectToWebSocket({
required String url,
required Map<String, String> headers,
required Map<String, dynamic> body,
}) async {
// Connect to the WebSocket with headers
final webSocket = await WebSocket.connect(
url,
headers: headers,
);

final channel = IOWebSocketChannel(webSocket);

// Send the initial JSON message
channel.sink.add(jsonEncode(body));

return channel;

} final headers = {
‘Authorization’: ‘Bearer ${widget.accessToken}’,
‘Accept’: ‘/’,
};
final body = {
‘guid’: ‘someguid’,
‘method’: ‘sub’,
‘data’: {
‘mode’: ‘ltpc’,
‘instrumentKeys’: [
‘NSE_INDEX|Nifty Bank’
], // Replace this with the actual instrument key
},
};
await getInstrumentDetails();
channel = await connectToWebSocket(
url: ‘wss://api.upstox.com/v2/feed/market-data-feed’,
headers: headers,
body: body);

  channel.stream.listen((message) {
    print('Received: $message');
  }); this is my code for connecting websocket in flutter but iam getting error 

Unhandled Exception: WebSocketException: Connection to ‘https://wsfeeder-api.upstox.com:0/market-data-feeder/v2/upstox-developer-api/feeds?requestId=93b67967-b14d-40ee-804f-9cb63b6531f5&code=DF1tU-cf30fca0-18c1-486e-ad56-801990bc8ec8#’ was not upgraded to websocket

this is the error iam getting please someone help me in this.

Same thread i believe