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

getting transport error on connect. #71

Closed
Tunmise-Adegoke opened this issue Jan 11, 2023 · 18 comments
Closed

getting transport error on connect. #71

Tunmise-Adegoke opened this issue Jan 11, 2023 · 18 comments

Comments

@Tunmise-Adegoke
Copy link

centrihhj

I tried connecting to a remote centrifugo deployment using the code above and got the error below,

centrifugo

I want to add that this is the version of the dart package I'm using centrifuge: ^0.9.2 and the version of the remote deployment is 4.1.2

@FZambia
Copy link
Member

FZambia commented Jan 14, 2023

Hello @Tunmise-Adegoke

How you are running it? Is it for web? (this sdk does not work for web at the moment, see open issue #34)

@Tunmise-Adegoke
Copy link
Author

Hello, I tried running it on mobile and I got a different error
centri 2

@FZambia
Copy link
Member

FZambia commented Jan 15, 2023

I see in the mobile logs that Centrifuge client successfully connected to the server and got unauthorized reason for subscription. Is that SocketException you observe raises from inside centrifuge-dart library? Or maybe its unrelated?

@Tunmise-Adegoke
Copy link
Author

I think it's from centrifugo because that's the only websocket on the app.

@FZambia
Copy link
Member

FZambia commented Jan 15, 2023

Can you check this? It may be from any other network activity I suppose - nothing in the exception says it's coming from the WebSocket. What's happening with the WebSocket connection after this error occurs btw?

@Tunmise-Adegoke
Copy link
Author

The websockets disconnects. I'm making some other network calls though but I don't think it should affect it. But the websocket disconnects after a minute.

@FZambia
Copy link
Member

FZambia commented Jan 15, 2023

If WebSocket disconnects a minute after being established this may be your proxy configuration which does not allow long-lived connections. So it may simply be a separate thing.

You may be right that the error comes from Centrifuge-dart. Or may be not. Since you have the reproducer you have all the power to check it. Or submit minimal reproducing steps without your app specifics so I could also take a closer look.

@Tunmise-Adegoke
Copy link
Author

This is my full code
tiny info I might add when connecting to the server through the centrifugo JS SDK it works well.
websocketurl =
'ws://realtime.mize.app/connection/websocket?cf_protocol_version=v2'
c1
c2
c3
c4

@FZambia
Copy link
Member

FZambia commented Jan 17, 2023

OMG, do you think I can run your screenshots?

Post the reproducing code (minimal, without your app specifics) as a repo on Github, give me instructions how to run it.

@Tunmise-Adegoke
Copy link
Author

Hello, This is a link to the repo I created
https://github.com/Tunmise-Adegoke/centrifugo_project
copy the code and clone it on your editor.
Make sure you have dart and flutter installed to run it then use an android emulator to run the app.

@FZambia
Copy link
Member

FZambia commented Jan 18, 2023

Hello @Tunmise-Adegoke

Thanks for posting example, I managed to run it for both MacOS desktop app and in Android emulator. In both cases it works without any issues. And WebSocket connection not closed at all. Here is an output when running in Android emulator:

Screenshot 2023-01-18 at 19 00 34

❯ flutter --version
Flutter 3.3.10 • channel stable • ssh://git@github.com/flutter/flutter.git
Framework • revision 135454af32 (5 weeks ago) • 2022-12-15 07:36:55 -0800
Engine • revision 3316dd8728
Tools • Dart 2.18.6 • DevTools 2.15.0

@FZambia
Copy link
Member

FZambia commented Jan 20, 2023

@Tunmise-Adegoke any updates? do you see a different output when running on your machine? Have you tried to update flutter to the latest version?

@Tunmise-Adegoke
Copy link
Author

Hello@FZambia, I gave you an unlimited token which works perfectly on my own end too. I'm have been trying to generate a token from my api to test it. I have been getting errors so that's why I haven't replied since.

@Tunmise-Adegoke
Copy link
Author

Hello @FZambia, as seen in your screenshot, your event was unsubscribed for unauthorised reasons. I'm facing the same issue. Please do you know the reason?

@FZambia
Copy link
Member

FZambia commented Jan 21, 2023

Yes, the reason is that the code uses dummy getToken for Subscription: https://github.com/Tunmise-Adegoke/centrifugo_project/blob/f39da4727641f48e0b5b0d87b60ee6b0e8cffffb/lib/client/client.dart#L55

Instead of:

    final subscription = client.newSubscription(
      channel,
      centrifuge.SubscriptionConfig(
        getToken: (centrifuge.SubscriptionTokenEvent event) {
          return Future.value('');
        },
      ),
    );

You should use whether:

    final subscription = client.newSubscription(
      channel,
      centrifuge.SubscriptionConfig(),
    );

Or load subscription token properly (now returning Future.value(''); in Subscription getToken tells SDK that client does not have permissions to subscribe on channel - this is described here).

I can't say exactly which way you need – depends on server permission configuration.

@Tunmise-Adegoke
Copy link
Author

I tired another method apart from this and it worked. I can connect and subscribe with ease.

@FZambia
Copy link
Member

FZambia commented Jan 29, 2023

Closing – as far as I understand all is good here. BTW, centrifuge-dart SDK will also support web in the next release - was just added in #73 .

@FZambia FZambia closed this as completed Jan 29, 2023
@Tunmise-Adegoke
Copy link
Author

Yay! For web.Thank you

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

2 participants