Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to handle connection timed out error #15

Open
kakopappa opened this issue Jul 22, 2020 · 3 comments
Open

How to handle connection timed out error #15

kakopappa opened this issue Jul 22, 2020 · 3 comments

Comments

@kakopappa
Copy link

Hi guys,

final events = EventSource(Uri.parse(sseEndpointUrl), initialReconnectDelay: new Duration(seconds:1));
 
try {
	events.events.listen((MessageEvent message) {
	  print('SSE event: ${message.data}');
	}).onError((error) => {
	  print('SSE event error: $error')
	});
} on SocketException catch(error) {
	print('$error');          
}

E/flutter (30879): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.1.100, port = 53342
E/flutter (30879):

This throws SocketException when the server is unavailable, it doesn't seem to goto onError or try catch. any idea how to handle it?

@goto-bus-stop
Copy link
Owner

could be a bug. i'm not using dart/flutter for anything lately but if you or anyone wants to look into this and maybe send a PR i'd review it.

@mikezander
Copy link

mikezander commented Jun 25, 2024

Did you ever find a solution to this? I had to put in a connection listener as a workaround.

@kakopappa
Copy link
Author

Copied the code to my project and change the code to reconnect on disconnect

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants