-
Notifications
You must be signed in to change notification settings - Fork 0
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
ValueError: SE: buffer too short #85
Comments
Can you add some more information? What data are you inputting? What exactly is the error/traceback? |
@uSpike When I'm negotiating options via IAC DO/WILL (or, rather, the server is doing the negotiation, I'm just accepting), one of two things happens: If I negotiate some features but, for
That's generated via this code: def handle_telnet_event(self, event):
print(event)
if isinstance(event, Command):
self.handle_telnet_command(event)
elif isinstance(event, SubCommand):
self.handle_telnet_subcommand(event)
else:
print(event)
def handle_telnet_command(self, event):
match event.cmd:
case Opt.NOP: return # Do nothing, no operation
case Opt.WILL | Opt.WONT | Opt.DO | Opt.DONT:
option = event.opt
cmd = event.cmd
bitmask = 1 << option
option_enabled = self.features & bitmask
match cmd:
case Opt.WILL:
if not option_enabled:
self.features |= bitmask
self.machine.send_command(Opt.DO, option)
case Opt.WONT:
if option_enabled:
self.features &= ~bitmask
self.machine.send_command(Opt.DONT, option)
case Opt.DO:
if not option_enabled:
if self.is_option_supported(option):
self.features |= bitmask
self.machine.send_command(Opt.WILL, option)
else:
self.machine.send_command(Opt.WONT, option)
case Opt.DONT:
if option_enabled:
self.features &= ~bitmask
self.machine.send_command(Opt.WONT, option)
case Opt.DM: return # We can't handle this
case Opt.BRK | Opt.EL:
self.command_input.value = ""
case Opt.EC:
self.command_input.value = self.command_input.value[:len(self.command_input.value)-1]
case _: return # Unknown command
def is_option_supported(self, feature):
return False # Currently we legitimately don't support anything
def handle_telnet_subcommand(self, event):
print(event) # We don't handle subcommands for now On the other hand, if I claim that all possible options are supported, I get a very different error:
(As an aside, 24 is a valid option: it asks the client about it's terminal type.) I've no idea what's happening with the first error since it doesn't make any sense. However, the second is problematic, particularly for MUDs; my recommendation would be to remove the Opt enum and just pass the option directly onto the client library/application, for two reasons:
|
OK thank you for the additional info.
This was changed in Also Can you test with the HEAD of |
@uSpike So, I updated to master and I still get that error, except that it doesn't throw an exception this time (and I'm not really sure what to do when I get an error like that -- do I just drop the problematic byte and move on?). That is: I get while True:
data = await reader.read(4096)
if not data:
break
if data:
received_data = bytearray()
events = self.machine.receive_data(data)
for event in events:
if isinstance(event, Command):
await self.handle_telnet_command(event.cmd, event.opt)
elif isinstance(event, SubCommand):
await self.handle_telnet_subcommand(event)
elif isinstance(event, Data):
received_data += event.msg
elif isinstance(event, Error):
print(f"Error: {event}")
else:
print(event)
if len(received_data) > 0:
await self.handle_telnet_recv(received_data) I don't know if this is a problem with telnetio or the application I'm connecting to. |
Also, for some reason if I ignore errors, the received bytes end up being garbage. I'm decoding them, so I think this might (?) be a bug. |
That's up to you. It seems that invalid data is being sent to the state machine, so it's up to you to continue or not. It's hard for me to help diagnose your issue without having a way to reproduce it. To answer your initial question, there are no known bugs. If you can log all of the events, or even better all of the input data which causes your error, I could help more easily. |
I'm getting this error when negotiating options. Is this a bug with the published wheel or am I doing something wrong?
The text was updated successfully, but these errors were encountered: