Closed User777ll closed 8 months ago
Can you provide a full and working app to reproduce the issue please?
My app also returned this error Here's the code:-
import flet as ft
import requests
import os
import atexit
socket_path = 'stdout.sock'
def get_remote_content():
# The URL with the actual endpoint
response = requests.get("[my_URL]/assets/update/content.json")
content = response.json()
return content.get("welcome_text", "Hello")
def cleanup_socket():
"""
Cleanup the Unix domain socket file if it exists.
"""
if os.path.exists(socket_path):
os.remove(socket_path)
def main(page: ft.Page):
# Register the cleanup function to run on app exit
atexit.register(cleanup_socket)
# Check if the socket file already exists and remove it
cleanup_socket()
# Create a Text widget with a default text
welcome_text = ft.Text(value="Hello", size=20)
# Function to update Text widget content
def update_content():
# Fetch the updated content
new_content = get_remote_content()
# Update the Text widget with the new content
welcome_text.value = new_content
page.update()
# Add Text widget to the page
page.add(welcome_text)
# Call the function to update content on app start
update_content()
ft.app(target=main)
@MaxXilon I removed that code around Flet's socket (you shouldn't mess with it really) and it worked like a charm:
My main.py
:
import flet as ft
import requests
def get_remote_content():
# The URL with the actual endpoint
response = requests.get("https://postman-echo.com/get?name=John%20Smith")
content = response.json()
return content["args"]["name"]
def main(page: ft.Page):
# Create a Text widget with a default text
welcome_text = ft.Text(value="Hello", size=20)
# Function to update Text widget content
def update_content():
# Fetch the updated content
new_content = get_remote_content()
# Update the Text widget with the new content
welcome_text.value = new_content
page.update()
# Add Text widget to the page
page.add(ft.SafeArea(welcome_text))
# Call the function to update content on app start
update_content()
ft.app(target=main)
requirements.txt
:
flet
requests
Command to build:
flet build apk
Flet version: 0.19.0
Result:
@User777ll Please provide a full and working app to reproduce the issue.
I've managed to reproduce "SocketException: Failed to create server socket (OS Error: File exists with given unix domain address), address = stdout.sock, port = 0" issue.
Working on the fix!
Fixed the app template - the app is not crashing with that error anymore when restarted multiple times. Rebuild your APK with flet build apk
to get updated template.
@FeodorFitsner Thanks 😊 it works fine, it no longer displays the error.
Description
I managed to launch my application, but for some reason when I open music in my application from Explorer it throws me out. the 3rd time I logged in and saw this: SocketException: Failed to create server socket (OS Error: File exists with given unix domain address), address = stdout.sock, port = 0
Code example to reproduce the issue:
Please note that this code works on the computer.
Describe the results you received:
Describe the results you expected: I expected everything to work. Additional information you deem important (e.g. issue happens only occasionally):
It is important that this problem only works in .apk When I run the program in vscode everything works.
the problem happens when I upload a file and click save, the file should be saved in page.client_storage and the page will refresh but when I click on the "Save file" button it throws me out, I can provide a video.
Flet version (
pip show flet
):Operating system:
Error on Android, but my version on computer: windows 10
Additional environment details: my imports in the application (from flet import from math import from time import sleep
import os import eyed3 import piglet)