vi / websocat

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

doesn't work with localhost, but ok with 127.0.0.1 (guessing related to IPv6) #194

Closed halturin closed 10 months ago

halturin commented 10 months ago

I got a weird issue. Tried to connect using websocat ws://localhost:9090/ws and got this error:

websocat: WebSocketError: I/O failure
websocat: error running

if I change the hostname to the IP address it works well.

my /etc/hosts has localhost records

127.0.0.1 localhost
::1 localhost

telnet command works well with the localhost hostname

$ telnet localhost 9090
Trying ::1...
Connection failed: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

I guess it tried the IPv6 address, got connection refused, and exited.

vi commented 10 months ago

It is know "happy eyeballs" deficiency in Websocat 1.0: https://github.com/vi/websocat/issues/23#issuecomment-1001550993

You can workaround with wc-c:tcp: if proper hostname handling is really needed (or just use specific IP address if it is just localhost).

halturin commented 10 months ago

Thanks for clarifying. It would be great to be mentioned in the README file.