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

Users are reporting that they cannot connect to the server #296

Open
wvzack opened this issue Dec 9, 2024 · 10 comments
Open

Users are reporting that they cannot connect to the server #296

wvzack opened this issue Dec 9, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@wvzack
Copy link

wvzack commented Dec 9, 2024

A lot of users are reporting that they are not able to use my project as they cant connect to it. I had a person who was saying it wasn't showing anything in the project (Crowsharki_) and they said this 5 minutes before I checked the output:

Added user: crowsharki_ with balance: 1000
Found user: crowsharki_
Found user: crowsharki_
CloudEvents: Disconnected. Reconnecting ... 1733750505.0936606
CloudEvents: Reconnected. 1733750505.3206973
CloudEvents: Disconnected. Reconnecting ... 1733750718.537903
CloudEvents: Reconnected. 1733750718.8245685
Found user: crowsharki_
^Z
[28]+  Stopped                 python3 cloud_requests.py

(at the end it stops because I restart the server)
While at the end it looks like they connected to the server they didn't (at least they claim) that the project was showing that the server was offline. There have also been a few times where in the cloud data logs the TO_HOST variable has been set many times and there was never a response but when I check with the server it was always on but did not seem to be monitoring the logs.

This seems like it happens after the server has been running for about a day non-stop without restarting the script, is this normal and I didn't know? (I am on the newest version of scratchattach 1.1.6)

Thanks

@FAReTek1
Copy link
Contributor

FAReTek1 commented Dec 10, 2024

im no specialist in thie area so all i could do is recommend an update

@FAReTek1
Copy link
Contributor

FAReTek1 commented Dec 10, 2024

also it might be helpful of you provided code (but make sure to remove username and password)

@wvzack
Copy link
Author

wvzack commented Dec 10, 2024

It is quite long but here is the script that deals with cloud requests

import scratchattach as sa
import main
import notifications
import leaderboard

session = sa.login_by_id("-----------------------------------", username="ByteBank")
cloud = session.connect_cloud("1026899140") #replace with your project id


client = cloud.requests()

@client.request
def ping(): #called when client receives request
    print("pong")
    return "pong" #sends back 'pong' to the Scratch project

@client.request
def get_balance():
    print(client.get_requester().lower())

    try:
        balance = main.get_value(client.get_requester().lower())
        formatted_message = f"You have {balance} dollar(s)"
        return balance
    except Exception as e:
        print(f"Error retrieving balance for {client.get_requester()}: {e}")
        return "Error retrieving balance. Check the Python console for details."

    

@client.request
def pay(to, amount):
	try:
		user = session.connect_user(to) # Returns a sa.User object. Warning: Any methods that require authentication will not work on the returned object
		if user.does_exist() == False: #Returns True if the user exists and False if the user is deleted. New in v1.7.3
			return("user non existent")

	except:
		return("user non existent")
	try:	
		print(client.get_requester())
		print(to)
		print(int(amount))
		username = str(client.get_requester()).lower()

		return_value = main.pay_user(client.get_requester().lower(), str(to).lower(), amount)
			
		if return_value == "failed":
			return("error")
		else:
			return main.get_value(username)  # Simply return the value from main.pay_user()
	except:
		return("error")



@client.request
def get_notifications():
    return notifications.view_notifications(str(client.get_requester()).lower())

@client.request
def get_all_info():
    username = str(client.get_requester()).lower()
    
    bytes = str(main.get_value(username))
    
    notif = notifications.view_notifications(str(client.get_requester()).lower())
    
    return bytes + "^" + notif
    
    
    

@client.request
def clear_notifications():
    notifications.clear_notifications(str(client.get_requester()).lower())
    return()


	
@client.request
def get_leaderboard():
	return leaderboard.get()
	


@client.event
def on_ready():
    print("Request handler is running")

client.start(thread=True) # thread=True is an optional argument. It makes the cloud requests handler run in a thread

Thanks! and please excuse me for my bad coding methods feel free to suggest stuff.

@TimMcCool
Copy link
Owner

After updating my Scratch backends to scratchattach 2.0, I experienced similar issues on one of the backends. This is definitely a scratchattach bug, unfortunately it's hard to reproduce and therefore hard to fix.

@TimMcCool TimMcCool added the bug Something isn't working label Dec 10, 2024
@wvzackscratch
Copy link

Would you recommend downgrading to 1.7.4? Or is there a way to reduce the amount it happens?

@zaid1442011
Copy link
Contributor

zaid1442011 commented Dec 11, 2024

It seems no matter what I do, I can't make my program to retrieve cloud variables from custom cloud servers (turbowarp and other servers). I even went as far as to host a test server and test my program. Maybe it's just a logical error in my program, but it may be related to this.

Edit: This has been happening since I migrated to v2.

@TheCommCraft
Copy link
Collaborator

TheCommCraft commented Dec 11, 2024 via email

@TheCommCraft
Copy link
Collaborator

TheCommCraft commented Dec 11, 2024 via email

@wvzack
Copy link
Author

wvzack commented Dec 11, 2024

is there a way to get the docs of v1.7.4 so i can run it on that version?

@SpyC0der77
Copy link

Go to commit history and looks for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants