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 connection failed (hosting on RaspberryPi 4B/arm64) #4878

Open
1 task done
Cr0wdSalad opened this issue Feb 12, 2025 · 3 comments
Open
1 task done

WebSocket connection failed (hosting on RaspberryPi 4B/arm64) #4878

Cr0wdSalad opened this issue Feb 12, 2025 · 3 comments
Assignees

Comments

@Cr0wdSalad
Copy link

Cr0wdSalad commented Feb 12, 2025

Duplicate Check

Describe the bug

I tried running a simple flet dynamic web app on a Raspberry Pi 4b (fresh install).

EDIT: same results when doing this on Ubuntu Server on an amd64 host.

Uvicorn runs the app with uvicorn test:app --port 8000 --host 0.0.0.0 but when i try to visit the app in a browser of another device in my local network the app gets stuck at loading (endless spinning indicator).

Firefox inspector shows Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
and Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/flet-app/ws.

all other GET requests receive response status code 200

there is no firewalll running on the host

uvicorn shows the 200 codes on opening/reloading the page and shows no issues.

i installed flet via pip install flet[all]

OS: Rasperry Pi OS (64bit Lite Bookworm / 64bit Lite Bullseye legacy)

i have no clue but i did not find anything about anyone hosting a flet app on an Raspberry Pi either besides @FeodorFitsner mentioning that flet does not run on the 32bit ones in an old issue.

Code sample

Code
import flet as ft
import flet.fastapi as flet_fastapi

async def main(page: ft.Page):
    await page.add_async(
        ft.Text("Hello, Flet!")
    )

app = flet_fastapi.app(main)

To reproduce

run any flet app on Raspberry Pi OS 64 lite (Bookworm or legacy Bullseye)

e.g. uvicorn test:app --port 8000 --host 0.0.0.0

Expected behavior

the app should load in browser

Screenshots / Videos

Captures

[Upload media here]

Operating System

Raspberry Pi OS Lite

Operating system details

Raspberry Pi OS (Lite/Desktop) (64-bit) Bookworm|Bullseye (legacy),
Raspberry Pi 4b / arm64

Flet version

0.26.0

Regression

No, it isn't

Suggestions

No response

Logs

Additional details

browser log

`Exception while loading service worker: Error: Service Worker API unavailable.
The current context is NOT secure.
Read more: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
loadServiceWorker http://192.168.0.61:8000/flutter_bootstrap.js:3
load http://192.168.0.61:8000/flutter_bootstrap.js:3
http://192.168.0.61:8000/flutter_bootstrap.js:13
flutter_bootstrap.js:3:3905
Injecting <script> tag. Using callback. flutter_bootstrap.js:1:1846
WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER. 2 canvaskit.js:14:383
WebGL warning: getParameter: The READ_BUFFER attachment is multisampled. 2
Source map error: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Stack in the worker:parseSourceMapInput@resource://devtools/client/shared/vendor/source-map/lib/util.js:163:15
_factory@resource://devtools/client/shared/vendor/source-map/lib/source-map-consumer.js:1066:22
SourceMapConsumer@resource://devtools/client/shared/vendor/source-map/lib/source-map-consumer.js:26:12
_fetch@resource://devtools/client/shared/source-map-loader/utils/fetchSourceMap.js:83:19

Resource URL: http://192.168.0.61:8000/flutter_bootstrap.js
Source Map URL: flutter.js.map
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19
Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
Uncaught : WebSocketChannelException: WebSocket connection failed. main.dart.js:3855:19`

content of the uncaught error:

Firefox can’t establish a connection to the server at ws://192.168.0.61:8000/ws. main.dart.js:7766:16
i http://192.168.0.61:8000/main.dart.js:3855
cGP http://192.168.0.61:8000/main.dart.js:6570
cGQ http://192.168.0.61:8000/main.dart.js:6719
$0 http://192.168.0.61:8000/main.dart.js:74462
cTm http://192.168.0.61:8000/main.dart.js:5461
cTY http://192.168.0.61:8000/main.dart.js:5463
$1 http://192.168.0.61:8000/main.dart.js:73170
(Async: MutationCallback)
cO7 http://192.168.0.61:8000/main.dart.js:5239
http://192.168.0.61:8000/main.dart.js:233691
c http://192.168.0.61:8000/main.dart.js:24
crA http://192.168.0.61:8000/main.dart.js:5468
c1W http://192.168.0.61:8000/main.dart.js:5574
Dt http://192.168.0.61:8000/main.dart.js:74498
adv http://192.168.0.61:8000/main.dart.js:73643
oi http://192.168.0.61:8000/main.dart.js:73641
f8 http://192.168.0.61:8000/main.dart.js:73212
t http://192.168.0.61:8000/main.dart.js:5260
0 http://192.168.0.61:8000/main.dart.js:65649
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
$0 http://192.168.0.61:8000/main.dart.js:65650
zi http://192.168.0.61:8000/main.dart.js:65418
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
zi http://192.168.0.61:8000/main.dart.js:65422
0 http://192.168.0.61:8000/main.dart.js:67037
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
$0 http://192.168.0.61:8000/main.dart.js:67041
c47 http://192.168.0.61:8000/main.dart.js:1227
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
cWR http://192.168.0.61:8000/main.dart.js:1230
c47 http://192.168.0.61:8000/main.dart.js:1204
1 http://192.168.0.61:8000/main.dart.js:79377
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
aCn http://192.168.0.61:8000/main.dart.js:79379
$1 http://192.168.0.61:8000/main.dart.js:79369
1 http://192.168.0.61:8000/main.dart.js:63503
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
aBQ http://192.168.0.61:8000/main.dart.js:63508
$1 http://192.168.0.61:8000/main.dart.js:63497
$1 http://192.168.0.61:8000/main.dart.js:67047
cRA http://192.168.0.61:8000/main.dart.js:8059
s http://192.168.0.61:8000/main.dart.js:8050
onEntrypointLoaded http://192.168.0.61:8000/flutter_bootstrap.js:22
didCreateEngineInitializer http://192.168.0.61:8000/flutter_bootstrap.js:1
c2q http://192.168.0.61:8000/main.dart.js:8552
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
c2q http://192.168.0.61:8000/main.dart.js:8554
c4p http://192.168.0.61:8000/main.dart.js:58366
s http://192.168.0.61:8000/main.dart.js:5270
$2 http://192.168.0.61:8000/main.dart.js:73231
u http://192.168.0.61:8000/main.dart.js:5256
c4p http://192.168.0.61:8000/main.dart.js:58368
http://192.168.0.61:8000/main.dart.js:235486
http://192.168.0.61:8000/main.dart.js:235482
dartProgram http://192.168.0.61:8000/main.dart.js:235484
http://192.168.0.61:8000/main.dart.js:235486

i ran FastAPI without flet without any problems. Other devices can connect and visiting the swaggerui in browser works too.
the Raspberry Pi is connected to the internet too.

using the most recent dev build of flet had the same results.

@Muddassir-Farooq-official

Also it's take 15 seconds for first time to load on any device

@Cr0wdSalad
Copy link
Author

Cr0wdSalad commented Feb 12, 2025

i have waited more than minutes while the WebSocket connection failed errors keep piling up until flets api lifecycle notices inactivity and terminates the current session.

I also tried running it with other ASGI servers like Hypercorn. Same result sadly

@Cr0wdSalad
Copy link
Author

Cr0wdSalad commented Feb 13, 2025

SOLVED: downgrading the package websockets to version 13.0.1 solved the issue

pip install websockets==13.0.1

the new version not only causes the warnings mentioned in other issue but is incompatible with recent flet when accessing a web app from another machine

@FeodorFitsner FeodorFitsner self-assigned this Feb 19, 2025
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

3 participants