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

error: WebSocket was closed before the connection was established #126

Open
dnlmrls opened this issue Aug 18, 2020 · 2 comments
Open

error: WebSocket was closed before the connection was established #126

dnlmrls opened this issue Aug 18, 2020 · 2 comments

Comments

@dnlmrls
Copy link

dnlmrls commented Aug 18, 2020

I am cretaing a function to send the wscat to background and redirecting a FIFO file (mkfifo ppp) to drop the data to send by the streaming.

**sendToBackground**() {
wscat -c wss://example.url -w 86400 < **ppp**
sleep 20
}

sendToBackgound &

echo -n '{"method": "login", "params": {"algo": "BASIC","pKey": "ABCD","sKey": "ABCD"}}' > **ppp**

After execute it, I get the next error:

error: WebSocket was closed before the connection was established

What can I do to drop data to sedn by the wss ?

Thanks.

@ghost
Copy link

ghost commented Jan 2, 2021

Did you manage to figure out a solution or workaround?
This was helpful for me: #43

@j1elo
Copy link

j1elo commented Sep 17, 2021

I've seen this happen with other programs, such as when trying to pipe cat and grep in a shell script, and the cause is typically that the program is expecting an attached TTY and an stdin channel, when actually these are not available, causing an immediately closed pipe, and both sides to close abruptly.

It's trivial to reproduce this issue with Docker, because the docker run command can be given -t (attach TTY), -i (stdin), or none of them. With none of them, wscat prints the "error: WebSocket was closed before the connection was established" message and it doesn't work.

Related:

This tool simply seems exclusively designed with interactive use in mind. Which is not bad at all, especially given the money users paid for it :-) But given that a common usage pattern for CLI tools is to end up scripting them, I guess the minimum that could be done is warning in the README about not to do so with this one...

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