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

Exception: Could not connected to Flet server in 30 seconds. #1484

Closed
msclock opened this issue Jun 15, 2023 · 2 comments
Closed

Exception: Could not connected to Flet server in 30 seconds. #1484

msclock opened this issue Jun 15, 2023 · 2 comments

Comments

@msclock
Copy link

msclock commented Jun 15, 2023

Description

I have the same bug as #1359 in wsl2 with a devcontainer env. It looks like a configuration error in server/config/config.go:96 and feels puzzling.

Code example to reproduce the issue:

import flet as ft
import logging

logging.basicConfig(level=logging.DEBUG)
logging.getLogger("flet_core").setLevel(logging.INFO)


def main(page: ft.Page):
    page.title = "Flet counter example"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(e):
        txt_number.value = str(int(txt_number.value) - 1)
        page.update()

    def plus_click(e):
        txt_number.value = str(int(txt_number.value) + 1)
        page.update()

    page.add(
        ft.Row(
            [
                ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
                txt_number,
                ft.IconButton(ft.icons.ADD, on_click=plus_click),
            ],
            alignment=ft.MainAxisAlignment.CENTER,
        )
    )


ft.app(port=8550, target=main, view=ft.WEB_BROWSER)

Describe the results you received:

python flet_test.py 
INFO:flet:Starting local Flet Server on port 8550...
INFO:flet:Flet Server found in: /home/vscode/.local/lib/python3.8/site-packages/flet/bin/fletd
INFO:flet:Web renderer configured: canvaskit
INFO:flet:Use color emoji: False
INFO:flet:Route URL strategy configured: path
INFO:flet:Connecting Flet Server at ws://127.0.0.1:8550/ws...
DEBUG:flet:Exited run_forever()
INFO:flet:Reconnecting Flet Server in 0.1 seconds
panic: error reading config file: While parsing config: yaml: unmarshal errors:
  line 1: cannot unmarshal !!str `version...` into map[string]interface {}

goroutine 1 [running]:
github.com/flet-dev/flet/server/config.init.0()
        /home/appveyor/projects/flet/server/config/config.go:96 +0x66e
INFO:flet:Connecting Flet Server at ws://127.0.0.1:8550/ws...
DEBUG:flet:Exited run_forever()
INFO:flet:Reconnecting Flet Server in 0.1 seconds
INFO:flet:Connecting Flet Server at ws://127.0.0.1:8550/ws...
DEBUG:flet:Exited run_forever()
...(always reconnecting here)
INFO:flet:Reconnecting Flet Server in 0.1 seconds
INFO:flet:Connecting Flet Server at ws://127.0.0.1:8550/ws...
DEBUG:flet:Exited run_forever()
INFO:flet:Reconnecting Flet Server in 0.1 seconds
Traceback (most recent call last):
  File "flet_test.py", line 34, in <module>
    ft.app(port=8550, target=main, view=ft.WEB_BROWSER)
  File "/home/vscode/.local/lib/python3.8/site-packages/flet/flet.py", line 88, in app
    __app_sync(
  File "/home/vscode/.local/lib/python3.8/site-packages/flet/flet.py", line 119, in __app_sync
    conn = __connect_internal_sync(
  File "/home/vscode/.local/lib/python3.8/site-packages/flet/flet.py", line 340, in __connect_internal_sync
    conn.connect()
  File "/home/vscode/.local/lib/python3.8/site-packages/flet/sync_websocket_connection.py", line 61, in connect
    raise Exception(
Exception: Could not connected to Flet server in 30 seconds.

Describe the results you expected:

Expect it run normally.

Additional information you deem important (e.g. issue happens only occasionally):

Flet version (pip show flet):

Name: flet
Version: 0.7.4
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: /home/vscode/.local/lib/python3.8/site-packages
Requires: flet-core, httpx, oauthlib, packaging, watchdog, websocket-client, websockets
Required-by:

Operating system:

OS: Linux dae1c1db0250 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Env: A configured devcontainer in wsl2

Additional environment details:

@FeodorFitsner
Copy link
Contributor

Viper (that Go library to work with configs) is configured the following way:

	viper.SetConfigName("config")
	viper.SetConfigType("yaml")

	if runtime.GOOS == "windows" {
		viper.AddConfigPath(filepath.Join(os.Getenv("ProgramData"), "flet"))
		viper.AddConfigPath(filepath.Join(os.Getenv("USERPROFILE"), ".flet"))
	} else {
		viper.AddConfigPath("/etc/flet")
		viper.AddConfigPath("$HOME/.config/flet")
	}
	viper.AddConfigPath(".")

What do you have in /etc/flet, $HOME/.config/flet and more importantly in the current directory when running flet app?

@msclock
Copy link
Author

msclock commented Jun 30, 2023

@FeodorFitsner I have tried it again and run it successfully.Maybe, there are some lock of failed installing deps with command apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio.Sorry to bother you.🤣🤣

@msclock msclock closed this as completed Jun 30, 2023
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