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

wscat breaks when IP of server changes #146

Open
Michael65589 opened this issue Mar 1, 2023 · 3 comments
Open

wscat breaks when IP of server changes #146

Michael65589 opened this issue Mar 1, 2023 · 3 comments

Comments

@Michael65589
Copy link

Hi,
I use WSCAT to communicate with a server in a Windows batch file. It works well but when I send a command to change the servers IP address WSCAT breaks and also my batch file.

Example:
wscat --connect ws://192.168.2.120:1234 -w 1 -x {"type":"write","name":"network","value":{"ip":"192.168.2.150","netmask":"255.255.255.0","gateway":"192.168.0.1"}}

The server receives the message, set and activate the new IP address but WSCAT does not get the answer because it expects the answer on the IP address 192.168.2.120.

Is there a way to do not wait for an answer?

Thanks
Michael

@lpinca
Copy link
Member

lpinca commented Mar 1, 2023

Make the server close the connection cleanly (call websocket.close()) before changing the IP.

@Michael65589
Copy link
Author

Michael65589 commented Mar 2, 2023 via email

@lpinca
Copy link
Member

lpinca commented Mar 2, 2023

You can try to use the --wait 0 option so that websocket.close() is called right after sending the command but there is no guarantee that it will work. The problem is that the command is sent and after some time (2 seconds by default) websocket.close() is called. In that time frame the server changes the IP so the closing handshake fails.

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