-
Notifications
You must be signed in to change notification settings - Fork 380
Details of thrown WebSocketException unavailable #1700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm also getting same error, I have followed the code from web-socket-cookbook-example. try {
final channel = WebSocketChannel.connect(
Uri.parse('ws://nixbin:3000'),
);
channel.stream.listen(
(message) => print('Received: $message'),
onError: (error) => print('Error: $error'),
onDone: () => print('Done'),
);
} catch (e) {
print('Connection error: $e');
} nixbin is host only accessible within my devices. A Dart VM Service on sdk gphone64 x86 64 is available at: http://127.0.0.1:42239/JIgF40mnNsc=/
E/flutter ( 7409): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketChannelException: Instance of 'WebSocketException'
E/flutter ( 7409):
The Flutter DevTools debugger and profiler on sdk gphone64 x86 64 is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:42239/JIgF40mnNsc=/
I/flutter ( 7409): Error: WebSocketChannelException: Instance of 'WebSocketException'
I/flutter ( 7409): Done
E/flutter ( 7409): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketChannelException: Instance of 'WebSocketException'
E/flutter ( 7409):
D/ProfileInstaller( 7409): Installing profile for com.example.project01 Is there anything missing? is it a bug for self-hosted websockets. |
I am also experiencing this issue |
So I did some digging, and it appears that the exception caught here is indeed of type 'WebSocketChannelException', looking into its code it appears to have 2 exposed variables:
As many of us have tried, both of these return "Instance of WebSocketException", which is indeed not what we want. However, if we look into that class' code, it also has the same 2 exposed variables. These are what we want! In order to get the error message itself, we'll need to access the WebSocketChannelException's inner's message. So in @fulstadev case, it'll look like this: Not sure if this is a bug or not since it seems weird that we'd have to access two identical objects just to get the error message, but doing the above did return the error message I've been looking for. |
Pinging so maybe my solution above can help you too... @kirstenkoa @MROvaiz Made it a new comment since I wasn't sure if editing a comment would actually notify you two. |
I think that was fixed in #1756 |
I'm trying to establish a websocket connection, through the following code:
Whenever I run this code in an iOS simulator, I get that the second
catch
clause (WebSocketChannelException
) is entered. But the problem is that I am unable to get any details / insight about the thrown error, e.g.:print(e.message)
simply givesInstance of 'WebSocketException'
print(e.inner.toString())
gives the sameThis is not very helpful for debugging; how can I check the actual details of the thrown Exception? I can't even find any
WebSocketException
class in the package source?The text was updated successfully, but these errors were encountered: