pythonpython-3.xfile-transferpackettftp

Python tftp handling error: "No options found in OACK"


I am using python 3's module tftpy to attempt to handle tftp style downloading of a file. However, when I run the application I get the following error:

\Python38\site-packages\tftpy\TftpStates.py", line 53, in handleOACK
    raise TftpException("No options found in OACK")
tftpy.TftpShared.TftpException: No options found in OACK

How do I get my python project to ignore OACK/ send a new request packet that doesn't include an OACK?

Disclaimer: This is my first time attempting to work with TFTP packets so I am fairly new. If the question I posed isn't the appropriate way to handle it, what should I be doing?

MORE DATA ON THE PROBLEM:

  1. I am using an external chip that is programmed to ignore OACK packet options.
  2. When I used C# and the TFTP.Net package the transfer worked, so I don't believe it is an issue with my TFTP server. However, as our main application is based in python I want to be able to handle this communication via python 3.
  3. I am running python 3.8.5
  4. On my server side it is saying it receives a packet with error code 8.

python Script:

import tftpy


client = tftpy.TftpClient('192.168.0.42', 69)
client.download('triplog.txt', 'faultlog.txt', packethook=None, timeout=5)

full traceback:

Failed to negotiate options: No options found in OACK
Traceback (most recent call last):
  File "C:\Users\selena\Documents\PythonScripts\TFTP\TFTPTestScript.py", line 23, in <module>
    client.download('triplog.txt', 'faultlog.txt', packethook=None, timeout=5)
  File "C:\Users\selena\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tftpy\TftpClient.py", line 58, in download
    self.context.start()
  File "C:\Users\selena\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tftpy\TftpContexts.py", line 402, in start
    self.cycle()
  File "C:\Users\selena\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tftpy\TftpContexts.py", line 202, in cycle
    self.state = self.state.handle(recvpkt, raddress, rport)
  File "C:\Users\selena\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tftpy\TftpStates.py", line 566, in handle
    self.handleOACK(pkt)
  File "C:\Users\selena\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tftpy\TftpStates.py", line 53, in handleOACK
    raise TftpException("No options found in OACK")
tftpy.TftpShared.TftpException: No options found in OACK
[Finished in 0.7s with exit code 1]

Solution

  • Credit @ewong for this workaround solution

    The code worked after adding in options when initializing the client even though I didn't need them. I'll be filing an issue @https://github.com/msoulier/tftpy to see if this is a bug that needs to be addressed or a deliberate choice.

    Solution code:

    import tftpy
    
    
    client = tftpy.TftpClient('192.168.0.42', 69, options={'blksize': 8})
    client.download('triplog.txt', 'faultlog.txt', packethook=None, timeout=5)