Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Flutter: Not working on some devices #1613

Closed
MderM opened this issue Jun 12, 2018 · 11 comments
Closed

Flutter: Not working on some devices #1613

MderM opened this issue Jun 12, 2018 · 11 comments

Comments

@MderM
Copy link

MderM commented Jun 12, 2018

While testing out https://flutter.io/cookbook/networking/web-sockets/ example, I found some strange behaviour I cannot explane to myself.

When connecting to a websocket server with an old Android device (Moto XT1092, Android 6.0.1) or the Android emulator (Android P) everything works fine.

When connecting with a Pixel 2 I get an 'Connection not upgraded' exception. Some debugging on the server side shows that the incoming request does not have the 'Upgrade' header. Looking at source codes I could not find any clue, why the code should be different on different devices.

Am I missing something?

@nex3
Copy link
Member

nex3 commented Jun 12, 2018

Can you try reproducing with the dart:io WebSocket class? This package just wraps that in a StreamChannel interface.

@MderM
Copy link
Author

MderM commented Jun 19, 2018

Seems to be someting with the sockets. Same beaviour when using the Websocket class. After flashing a newer Android, it won't connect on the XT1092 either.

@MderM
Copy link
Author

MderM commented Jun 27, 2018

Should this then be moved to dart-sdk? Or flutter? I don't know what might be different under the hood on different android versions/emulator/real devices...

@NTMS2017
Copy link

I am having problem to: I can't connect using local network ip such as ws://192.168.1.22:1024 (or with our : ).

Also Seems I cannot find any good documentation to connect my Flutter mobile app using my local wireless network to connect to my local network socket services.

@MderM
Copy link
Author

MderM commented Jul 3, 2018

I have to clarify this:

After latest flutter updates, it works when the device is connected via WiFI but it is sending the wrong headers when using LTE.

In my opinion there shouldn't be a difference in how a device is connecting to a websocket server.

And again, this might be the wrong place for the issue. It would be nice if it could be moved to the proper location, if this is the case.

@g-balas
Copy link

g-balas commented Sep 28, 2018

Any news for this ? Is is stable enought for a production application with flutter ?

@hariangr
Copy link

hariangr commented Sep 3, 2019

My websocket app work on debug mode but doesn't on release mode

@natebosch
Copy link
Member

It sounds like this issue is related strictly to networking in flutter - please follow or reply on https://github.com/flutter/flutter/issues/29688

There isn't anything we can do in this package to work around flutter emulator, device, or permission issues.

@bus710
Copy link

bus710 commented Sep 28, 2019

In addition to the permission, some cases might have issue with the websocket upgrade.

I originally had the same issue as others when I was using Golang's default net/http websocket but I could solve with Gorilla package's websocket with the upgrader.

https://github.com/gorilla/websocket/tree/master/examples/echo

I suspect that the server should have a websocket upgraded already to serve the websocket client of dart:io and web_socket_channel so that the code in the link may help somebody.

(Sorry for being late to the discussion)

@al-sadi
Copy link

al-sadi commented Sep 24, 2021

I am having the same issue as well. A simple websocket app works perfectly fine on a Samsung A10 device and iPhone 6, but does not work on Xiaomi pocophone f1. I am using piesocket.com (Free tier)

@al-sadi
Copy link

al-sadi commented Oct 24, 2021

I am having the same issue as well. A simple websocket app works perfectly fine on a Samsung A10 device and iPhone 6, but does not work on Xiaomi pocophone f1. I am using piesocket.com (Free tier)

OK, the issue was about adding: <uses-permission android:name="android.permission.INTERNET" /> to my Android Manifest.
Some background: I used to USB-debug my websocket app with Samsung A10 device and iPhone 6. My Xiaomi pocophone f1 had some issues with the USB Port so I used to build an APK and send it to my Poco f1 through Telegram. It seems that for production apps, you must use android.permission.INTERNET while this is being taken care of during Flutter run (Debugging mode).

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

9 participants