vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
7.17k stars 278 forks source link

Exchange n messages and then exit #65

Open FedericoPonzi opened 4 years ago

FedericoPonzi commented 4 years ago

Is there any way to handle something like --one-message, but generalized to n messages? In my case, the webservice I'm contacting will respond back to my single message with two messages, and I don't want to be rude by closing the connection too early.

Thanks

vi commented 4 years ago

It can be implemented; not sure how useful would it be. Are there other cases when message limits can be beneficial?

be rude by closing the connection too early.

Is it bad? Does it cause errors or warnings on server side? Or do you actually need content of the second message?

edisinovcic commented 4 years ago

This would be useful for my use case also. Having some kind of a termination clause (for example response containing a specific string in a response).

FedericoPonzi commented 4 years ago

It can be implemented; not sure how useful would it be. Are there other cases when message limits can be beneficial?

be rude by closing the connection too early.

Is it bad? Does it cause errors or warnings on server side? Or do you actually need content of the second message?

Yes, in my case that triggers an error on the server side. I've worked around it by using | tail -n2.

vi commented 4 years ago

Implemented relevant options and published a (not even a pre-release) build: https://github.com/vi/websocat/releases/tag/v2.0.0-alpha0

Please test.