Fix IllegalStateException triggered by a successful connection attempt

- Fixes #1467
- Provide more information about the tasks and promises on exception for easier debugging