Hello,
I am working with a login that works with websocket, when I send the correct parameters, the login connection is provided.It doesn't return me a statuscode 201 style message even if the connection is established.When I enter it wrong on purpose, it returns me this as an errorWebSocketChannelException: WebSocketChannelException: WebSocketException: Connection to 'the url i entered#' was not upgraded to websocket the code is like this;
IOWebSocketChannel channel = new IOWebSocketChannel.connect("THE URL I ENTERED",headers: {"USER_ID":widget.user,"PASSWORD":widget.password},);
channel.stream.listen(
(dynamic message) {
debugPrint('message $message');
channel.sink.close(status.goingAway);
print(status.goingAway);
},
onDone: () {
debugPrint('ws channel closed');
},
onError: (error) {
print('socket closed: reason=[${channel.closeReason}], code:[${channel.closeCode}]');
debugPrint('ws error $error');
},
);
message i get in terminal
I/flutter ( 5598): socket closed: reason=[null], code:[null]
I/flutter ( 5598): ws error WebSocketChannelException: WebSocketChannelException: WebSocketException: Connection to 'THE URL I ENTERED' was not upgraded to websocket
I/flutter ( 5598): ws channel closed
My question is, I want it to return server respond code when I entered correctly or when I entered wrong. I did the same thing in different languages such as python, and it gives me feedback. but here it comes only as null, I searched everywhere for the solution of this error for about 4 days, but I couldn't find it.waiting for you to help me
Best Regards