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

Disconnect causing EOF errors #113

Open
5tanly opened this issue Dec 12, 2018 · 3 comments
Open

Disconnect causing EOF errors #113

5tanly opened this issue Dec 12, 2018 · 3 comments

Comments

@5tanly
Copy link

5tanly commented Dec 12, 2018

This is the code I am using to reconnect/connect to the server

async def reco(self):
try:
self.connection.disconnect()
await asyncio.sleep(60)
except:
pass
self.connection.connect()
await asyncio.sleep(3)
packet = serverbound.play.ChatPacket()
packet.message = '/server witch'
self.connection.write_packet(packet)
print('Logged In')

This is the error I get when I execute that code (only happens at the self.connection.disconnect() line from what I can see i.e. when reconnecting)

Exception in thread Networking Thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 462, in run
self._run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 496, in _run
self.connection.file_object, timeout=read_timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 535, in read_packet
length = VarInt.read(stream)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/types/basic.py", line 113, in read
raise EOFError("Unexpected end of message.")
EOFError: Unexpected end of message.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 466, in run
self.connection.handle_exception(e, sys.exc_info())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 412, in handle_exception
raise
(*exc_info)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/future/utils/init.py", line 415, in raise

raise exc.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 462, in run
self._run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 496, in _run
self.connection.file_object, timeout=read_timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/connection.py", line 535, in read_packet
length = VarInt.read(stream)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/minecraft/networking/types/basic.py", line 113, in read
raise EOFError("Unexpected end of message.")
EOFError: Unexpected end of message.

Sorry for the garbage formatting I don't know how GitHub works with codeblocks, tilda doesnt seem to respect my tabs/enters

@5tanly
Copy link
Author

5tanly commented Dec 13, 2018

No matter how or where I use self.connection.disconnect(immediate=True) i always get EOF errors

@ammaraskar
Copy link
Owner

Take a look at the handle_exception argument to Connection here: https://pycraft.readthedocs.io/en/latest/connecting.html#minecraft.networking.connection.Connection

@ammaraskar
Copy link
Owner

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