Unhandled header!
walirt opened this issue · 15 comments
I try to implement zmodem protocol using zmodemjs on websocket
And follow the zmodemjs documentation
But when I input rz and sz commands, I get an error. I do n’t know how to solve it.
Can you give me some suggestions or solutions?
Thank you
Platform and software version
Ubuntu 18.04.3 LTS
lrzsz version 0.12.21rc
Console error output
When running rz
When running sz
This problem has troubled me for a long time
Thanks again
Best advice I can offer is to refer to existing implementations (e.g., ttyd). There’s also an example sz CLI implementation in the repo.
The code implementation completely refers to the existing implementation, but it still reports an error
Is this a back-end problem?
Can you provide a test case that fails?
yes
the test case in this repository can reproduce this situation
you can enter rz and sz commands in the terminal
then you will find the error in the console
thanks
Can you please rework that to a test case for this repository, some JS code that demonstrates how the library as it stands is behaving contrary to its documentation?
I found out why I didn't set the sender callback
I'm sorry
But then there's a new error. SZ sometimes returns an error
Does this mean that I need to send "OO" after saving the file to disk
Like this
Zmodem.Browser.save_to_disk(
xfer._spool,
xfer.get_details().name
)
that.ws.send(new Uint8Array([79, 79]))
I’m closing this, as there hasn’t yet materialized a test case that shows a reproducible bug.
I do recognize that it’s hard to get use of this library correct. I’d also accept a PR to add examples of correct usage.
@walirt Hello, I encountered the same problem as you, how did you solve it? Where do you mean to set the sender callback? How to solve the subsequent OO problem? Can you provide an simple example? thanks
@walirt Hi,I encountered the same problem as you, Have you solved it, I want to see your example,thanks.
建议参考一下这个项目,逻辑是一样的:https://github.com/huyuan1999/django-webssh
I have solved the problem!
copy for example
let zsentry = new Zmodem.Sentry( {
to_terminal(octets) { .. }, //i.e. send to the terminal
sender(octets) { .. }, //i.e. send to the ZMODEM peer
on_detect(detection) { .. }, //for when Sentry detects a new ZMODEM
on_retract() { .. }, //for when Sentry retracts a Detection
} );
modify code
sender(octets) { websocket.send(new Uint8Array(octets) }
I have solved the problem!
copy for example
let zsentry = new Zmodem.Sentry( {
to_terminal(octets) { .. }, //i.e. send to the terminalsender(octets) { .. }, //i.e. send to the ZMODEM peer on_detect(detection) { .. }, //for when Sentry detects a new ZMODEM on_retract() { .. }, //for when Sentry retracts a Detection
} );
modify code
sender(octets) { websocket.send(new Uint8Array(octets) }
My code is the same as yours, but it still reports errors
Uncaught PROTOCOL: Only thing after ZFIN should be “OO” (79,79)
Your back-end code needs to process the'OO' code returned by the server. This process requires the cooperation of the front and back ends.You can refer to this project: https://github.com/huyuan 1999/django-webssh, the relevant logic in ssh.py