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

WebSocket closed with status code: 1002 #82

Closed
wolnynick opened this issue Dec 29, 2021 · 3 comments
Closed

WebSocket closed with status code: 1002 #82

wolnynick opened this issue Dec 29, 2021 · 3 comments

Comments

@wolnynick
Copy link

wolnynick commented Dec 29, 2021

Hi, I'm trying to make connection with HUB and default transport setting is throwing error with 1002 code. Why do I need to set up transport: HttpTransportType.serverSentEvents ? It shouldn't be managed automatically by library by chosing the best option? Or maybe there is possibility to achieve it?

    connection = HubConnectionBuilder()
        .withUrl(
          'https://url/hub/chat',
          HttpConnectionOptions(
            // transport: HttpTransportType.serverSentEvents, (Only when I uncomment this line then I can make connection)
            logging: (level, message) => print('test: $message'),
          ),
        )
        .build();

    await connection.start();

Error without transport: HttpTransportType.serverSentEvents:

Starting HubConnection.
Starting connection with transfer format 'TransferFormat.text'.
Sending negotiation request: https://url/hub/chat/negotiate.
Selecting transport 'HttpTransportType.webSockets'.
(WebSockets transport) Connecting.
WebSocket connected to wss://url/hub/chat?id=ARXbK9CjBkJjxWPSAHTzHg.
The HttpConnection connected successfully.
Sending handshake request.
(WebSockets transport) sending data. String data of length '32'.
Using HubProtocol 'json'.
(WebSockets transport) socket closed.
HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connected.
Connection disconnected with error 'Exception: WebSocket closed with status code: 1002 (null).'.
HubConnection.connectionClosed(Exception: WebSocket closed with status code: 1002 (null).) called while in state HubConnectionState.connecting.
HttpConnection.stopConnection(null) called while in state ConnectionState.disconnected.
Call to HttpConnection.stopConnection(null) was ignored because the connection is already in the disconnected state.
 Hub handshake failed with error 'Exception: WebSocket closed with status code: 1002 (null).' during start(). Stopping HubConnection.
Call to HttpConnection.stop(Exception: WebSocket closed with status code: 1002 (null).) ignored because the connection is already in the disconnected state.
HubConnection failed to start successfully because of error '{Exception: WebSocket closed with status code: 1002 (null)..toString()}'
@minhnhatvdl
Copy link

I have the same problème. Anyone can explain me why ?

@misici234
Copy link

The reason is a bug in the package. I reported it more than a year ago, see https://github.com/jamiewest/signalr_core/issues/38. If you want to make it work then fix it yourself and submit a pull request here. Thanks.

@Invectys
Copy link

This error occurs when name to hub is incorrect

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

No branches or pull requests

5 participants