WEBSOCAT(1)
πΈ NAME πΈ
okay bestie, welcome to the websocat(1) page from the User Commands manual β and the name is literally websocat β websocat π
yes, she said the same word twice, we move.
β¨ DESCRIPTION β¨
This is websocat 1.14.1 by Vitaly "_Vi" Shukela <vi0oss@gmail.com> β a command-line client for web sockets, like netcat/curl/socat for ws://. No cap, that's the whole vibe π«Ά.
π§ USAGE π§
- simple client:
websocat ws://URL | wss://URL
(simple client)
- simple server:
websocat -s port
(simple server)
- advanced mode:
websocat [FLAGS] [OPTIONS] <addr1> <addr2>
(advanced mode)
π FLAGS π
some flags are hidden, see --help=long β yes bestie, there are hidden ones, don't @ me π.
-e,--set-environmentβ setWEBSOCAT_*environment variables when doingexec:/cmd:/sh-c:. Currently it'sWEBSOCAT_URIandWEBSOCAT_CLIENTfor request URI and client address (if TCP). β οΈ Beware of ShellShock or similar security problems β this is not a drill.-E,--exit-on-eofβ close a data transfer direction if the other one reached EOF.--jsonrpcβ format messages you type as JSON RPC 2.0 method calls. First word becomes method name, the rest becomes parameters, possibly automatically wrapped in[]. cute.-0,--null-terminatedβ use\0instead of\nfor linemode. Also:--no-fixupsto discover what is being inserted automatically and read the full manual about Websocat internal workings. (Yes, that's the exact note, bestie.)-1,--one-messageβ send and/or receive only one message. Use with--no-closeand/or-u/-U.--oneshotβ serve only once. Not to be confused with-1(--one-message). They are different girls.--print-ping-rttsβ print measured round-trip-time to stderr after each received WebSocket pong.-qβ suppress all diagnostic messages, except of startup errors.-s,--server-modeβ simple server mode: specify TCP port oraddr:portas single argument.-S,--strictβ strict line/message mode: drop too long messages instead of splitting them, drop incomplete lines.-k,--insecureβ accept invalid certificates and hostnames while connecting to TLS.-u,--unidirectionalβ inhibit copying data in one direction.-U,--unidirectional-reverseβ inhibit copying data in the other direction (or maybe in both directions if combined with-u).-vβ increase verbosity level to info or further.-b,--binaryβ send message to WebSockets as binary messages.-n,--no-closeβ don't send Close message to websocket on EOF.-t,--textβ send message to WebSockets as text messages.--base64β encode incoming binary WebSocket messages in one-line Base64. If--binary-prefix(see--help=full) is set, outgoing WebSocket messages that start with the prefix are decoded from base64 prior to sending.
π OPTIONS π
some options are hidden, see --help=long.
--socks5 <auto_socks5>β use specifiedaddress:portas a SOCKS5 proxy. Example:--socks5 127.0.0.1:9050.--basic-auth <basic_auth>β addAuthorization: BasicHTTP request header with this base64-encoded parameter. Also available asWEBSOCAT_BASIC_AUTHenvironment variable.--basic-auth-file <basic_auth_file>β addAuthorization: BasicHTTP request header base64-encoded content of the specified file.-B,--buffer-size <buffer_size>β maximum message size, in bytes [default:65536].--close-reason <close_reason>β close connection with a reason message. This option only takes effect if--close-status-codeoption is provided as well.--close-status-code <close_status_code>β close connection with a status code.-H,--header <custom_headers>...β add custom HTTP header to websocket client request. Separate header name and value with a colon and optionally a single space. Can be used multiple times. Note that single-Hmay eat multiple further arguments, leading to confusing errors. Specify headers at the end or with equal sign like-H='X: y'.--server-header <custom_reply_headers>...β add custom HTTP header to websocket upgrade reply. Separate header name and value with a colon and optionally a single space. Can be used multiple times. Note that single-Hmay eat multiple further arguments, leading to confusing errors.--header-to-env <headers_to_env>...β forward specified incoming request header toH_*environment variable forexec:-like specifiers.-h,--help <help>β see the help.--help=shortis the list of easy options and address types;--help=longlists all options and types (see[A]markers);--help=docalso shows longer description and examples.--max-messages <max_messages>β maximum number of messages to copy in one direction.--max-messages-rev <max_messages_rev>β maximum number of messages to copy in the other direction.--conncap <max_parallel_conns>β maximum number of simultaneous connections for listening mode.--origin <origin>β add Origin HTTP header to websocket client request.--pkcs12-der <pkcs12_der>β Pkcs12 archive needed to accept SSL connections, certificate and key. A command to output it:openssl pkcs12 -export -out output.pkcs12 -inkey key.pem -in cert.pem. Use with-s(--server-mode) option or with manually specified TLS overlays. Seemoreexamples.mdfor more info.--pkcs12-passwd <pkcs12_passwd>β password for--pkcs12-derpkcs12 archive. Required on Mac.-p,--preamble <preamble>...β prepend copied data with a specified string. Can be specified multiple times.-P,--preamble-reverse <preamble_reverse>...β prepend copied data with a specified string (reverse direction). Can be specified multiple times.--restrict-uri <restrict_uri>β when serving a websocket, only accept the given URI, like/ws. This liberates other URIs for things like serving static files or proxying.-F,--static-file <serve_static_files>...β serve a named static file for non-websocket connections. Argument syntax:<URI>:<Content-Type>:<file-path>. Argument example:/index.html:text/html:index.html. Directories are not and will not be supported for security reasons. Can be specified multiple times. Recommended to specify them at the end or with equal sign like-F=..., otherwise this option may eat positional arguments.--ua <useragent>β setUser-Agentrequest header to this value. Similar to setting it with-H.--protocol <websocket_protocol>β specify thisSec-WebSocket-Protocol:header when connecting.--server-protocol <websocket_reply_protocol>β force thisSec-WebSocket-Protocol:header when accepting a connection.--websocket-version <websocket_version>β override theSec-WebSocket-Versionvalue.--ping-interval <ws_ping_interval>β send WebSocket pings each this number of seconds.--ping-timeout <ws_ping_timeout>β drop WebSocket connection if Pong message not received for this number of seconds.
π¦ ARGS π¦
<addr1>β in simple mode, WebSocket URL to connect. In advanced mode first address (there are many kinds of addresses) to use. See--help=typesfor info about address types. If this is an address for listening, it will try serving multiple connections.<addr2>β in advanced mode, second address to connect. If this is an address for listening, it will accept only one connection.
π Basic examples π
- Command-line websocket client:
websocat ws://ws.vi-server.org/mirror/
- WebSocket server:
websocat -s 8080
- WebSocket-to-TCP proxy:
websocat --binary ws-l:127.0.0.1:8080 tcp:127.0.0.1:5678
π Partial list of address types π
ws://β insecure (ws://) WebSocket client. Argument is host and URL.wss://β secure (wss://) WebSocket client. Argument is host and URL.ws-listen:β WebSocket server. Argument is host and port to listen.wss-listen:β listen for secure WebSocket connections on a TCP port.tcp:β connect to specified TCP host and port. Argument is a socket address.tcp-listen:β listen TCP port on specified address.ssl-listen:β listen for SSL connections on a TCP port.sh-c:β start specified command line usingsh -c(even on Windows).cmd:β start specified command line usingsh -corcmd /C(depending on platform).readfile:β synchronously read a file. Argument is a file path.writefile:β synchronously truncate and write a file.appendfile:β synchronously append a file.udp:β send and receive packets to specified UDP socket, from random UDP port.udp-listen:β bind an UDP socket to specifiedhost:port, receive packet.-β read input from console, print to console. Uses threaded implementation even on UNIX unless requested by--async-stdioCLI option.mirror:β simply copy output to input. No arguments needed.literalreply:β reply with a specified string for each input packet.literal:β output a string, discard input.random:β generate random bytes when being read from, discard written bytes.
π Partial list of overlays π
broadcast:β reuse this connection for serving multiple clients, sending replies to all clients.autoreconnect:β re-establish underlying connection on any error or EOF.foreachmsg:β execute something for each incoming message.log:β log each buffer as it pass though the underlying connector.
See more address types with the --help=long option. See short examples and --dump-spec names for most address types and overlays with --help=doc option.
okay that's the whole page, bestie π β footer vibes: websocat 1.14.1, date July 2026, manual name WEBSOCAT(1). Go be the main character of your socket connection π«Άβ¨
π¦ where this page comes from
- arch rolling: websocat 1.14.1-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms