Skip to content
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

If WSS connection fails the plugin cannot try other transports (SSE and LP) #38

Closed
misici234 opened this issue Jan 29, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@misici234
Copy link

When I run the following test code
main.txt
I get this error
flutter: SigChar url is https://confidential_link/...
flutter: Starting HubConnection.
flutter: Starting connection with transfer format 'TransferFormat.text'.
flutter: Sending negotiation request: https://confidential_link/...
flutter: Selecting transport 'HttpTransportType.webSockets'.
flutter: (WebSockets transport) Connecting.
flutter: WebSocket connected to wss://confidential_link/...
flutter: The HttpConnection connected successfully.
flutter: Sending handshake request.
flutter: (WebSockets transport) sending data. String data of length '32'.
flutter: Using HubProtocol 'json'.
flutter: (WebSockets transport) socket closed.
flutter: HttpConnection.stopConnection(null) called while in state ConnectionState.disconnecting.
flutter: Connection disconnected with error 'Exception: Server timeout elapsed without receiving a message from the server.'.
flutter: HubConnection.connectionClosed(Exception: Server timeout elapsed without receiving a message from the server.) called while in state HubConnectionState.disconnected.
flutter: Hub handshake failed with error 'Exception: Server timeout elapsed without receiving a message from the server.' during start(). Stopping HubConnection.
flutter: Call to HttpConnection.stop(Exception: Server timeout elapsed without receiving a message from the server.) ignored because the connection is already in the disconnected state.
flutter: HubConnection failed to start successfully because of error '{Exception: Server timeout elapsed without receiving a message from the server..toString}'.
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: Exception: Server timeout elapsed without receiving a message from the server.

Our ASP.NET Core application doesn't support WebSockets but it supports Server Sent Events for some reason which I don't know.
Your plugin has a problem to switch from WSS to SSE if it fails to communicate using WSS. When I explicitly specify SSE
logging: (level, message) => print(message), transport: HttpTransportType.serverSentEvents);
then it works fine. The signalr_client 0.1.6 doesn't have this problem and that's the reason I still use it but I want to replace it with your plugin as soon as you resolve this problem. Please go there and see how they made this work.
If you need our URL to test then let me know but you need to disable WSS transport on your server and you'll be fine to reproduce this issue.

@misici234
Copy link
Author

here is correct line
final httpOptions = new HttpConnectionOptions(logging: (level, message) => print(message), transport: HttpTransportType.serverSentEvents);

@misici234
Copy link
Author

I was looking the code and the problem is in web_socket_transport.dart file.
Function
@override Future<void> connect(String url, TransferFormat transferFormat) async {}
should throw an Exception if it cannot connect and should not have its own try/catch block so that outside try/catch block can catch the Exception and move to next transport. Hope this helps.

@misici234
Copy link
Author

Hi Jamie, are you going to fix this problem? As far as I can see this is not trivial fix and I don't feel comfortable to do it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants