Closed vanelizarov closed 5 years ago
The problem was in incorrect formatting in file lib/src/transport.dart
Seems to be fixed in #8
Hi, was this an error in your fork or the problem reproduces with code in this repo too?
The problem reproduces with code in this repo, in my fork and in #8 I've fixed it Actually, it's in lines 10-11, when TransportBuilder typedef is defined
Any updates?..
Sorry, @mogol is a bit busy these days – as soon as he has time he will look at this
@vanelizarov I will go through the code, thanks.
But can you explain how it is possible that formatting changes behavior? Very curious
@mogol
I thought that the problem was in formatting, because as soon as I fixed it in transport.dart
file, the problem stopped occuring. Maybe that was because I was running my app in flutter's debug mode, which is, as I know, kind of interpreter mode. So, transport.dart
was not compiled when app started and when it came to it, app crashed. Unfortunately, this bug suddenly started appearing again, so this assumption was initially wrong.
I will check the issue over the weekends.
@mogol Tried running on Android simulator - app didn't crash after recovering connection. It seems like this bug is reproducible only on iOS
@vanelizarov, I can't reproduce it. can you reproduce the issue
flutter channel stable
(optional)
? If yes, please share flutter doctor -v
again
I use
[✓] Flutter (Channel unknown, v1.4.4, on Mac OS X 10.14.4 18E226, locale en-SG)
• Flutter version 1.4.4 at /Users/german/Projects/github/flutter
• Framework revision 3b3f6c7a04 (9 days ago), 2019-03-27 13:56:23 -0700
• Engine revision 0d83a2ecd1
• Dart version 2.2.1 (build 2.2.1-dev.2.0 None)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
...
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2, Build version 10E125
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[!] Android Studio (version 3.3)
...
[✓] IntelliJ IDEA Community Edition (version 2018.3.5)
...
[✓] VS Code (version 1.32.3)
...
[✓] Connected device (1 available)
• iPhone Xʀ • 2854D84D-6668-4D1D-9A36-7646CF88B7B8 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
@mogol yeah, this bug can be reproduced with toolchain you described
flutter doctor -v:
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.5 18F96h, locale en-RU)
• Flutter version 1.2.1 at /Users/vanelizarov/flutter
• Framework revision 8661d8aecd (7 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/vanelizarov/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2, Build version 10E125
• ios-deploy 2.0.0
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 33.4.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] VS Code (version 1.32.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.24.0
[✓] Connected device (1 available)
• vanelizarov-iphone • c25ab95a7a881c4a4d782f7ebbff2c392d44bb69 • ios • iOS 12.3
• No issues found!
To be honest, my api requires token to be supplied in centrifuge client to support any channel subscriptions. So, the only addition to demo app is http request to get such token in initState
and then call to setToken
method on _centrifuge
prop:
import 'package:http/http.dart' as http;
...
@override
void initState() {
final authUrl = 'http://10.78.206.237:8001/api/v1/pub/ws_pub_auth';
http.post(authUrl).then((res) {
final String token = json.decode(res.body)['token'];
print(token);
final centUrl = 'ws://10.78.206.237:8001/connection/websocket?format=protobuf';
_centrifuge = centrifuge.createClient(centUrl);
_centrifuge.setToken(token);
});
_controller = ScrollController();
super.initState();
}
...
Here's the video demonstration: https://drive.google.com/open?id=1DGip5Rn-gG1a8KP-Q3yeJeWLRxhEgm0-
What is used as server? lib or server ? what version?
I test with centrifugo2.herokuapp.com and no crashes so far.
@mogol we use latest Docker image centrifugo/centrifugo:v2.1
How can I connect to app on heroku? I have tried connecting via ws://centrifugo2.herokuapp.com/connection/websocker?format=protobuf
with no luck, client stays permanently in connecting state
I use this
@override
void initState() {
final url =
'wss://centrifugo2.herokuapp.com/connection/websocket?format=protobuf';
Future<void>.delayed(Duration(seconds: 5)).then((_) {
print('Set token');
_centrifuge = centrifuge.createClient(url);
_centrifuge.setToken(
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0c3VpdGVfand0In0.hPmHsVqvtY88PvK4EmJlcdwNuKFuy3BGaF7dMaKdPlw');
});
_controller = ScrollController();
super.initState();
}
@mogol Cool, thanks, will try it now
@mogol Hmmm, app is not crashing if I connect to heroku instance. Will try to check with my colleagues, maybe something is wrong in server config.
Closing as can't reproduce with a permission from @vanelizarov
@vanelizarov Hey, did you find the solution?
I've installed centrifuge lib in my flutter app. Not the version from pub, but directly from my fork of main repo. Suddenly I've experienced a bug: app crashes after recovering internet connection. There were no error messages in console, only 'Lost connection to device'.
Steps to reproduce (on iOS simulator):
After doing that, app crashes after a couple of sesonds. Tried launching app through Xcode, but when app crashes, there are also no error logs, only
Message from debugger: Terminated due to signal 13
.flutter doctor
: