websockets / wscat Goto Github PK
View Code? Open in Web Editor NEWWebSocket cat
License: MIT License
WebSocket cat
License: MIT License
First of all, this is an amazing and simple solution.
I am using wscat
in order to get data from my server, but since the same object is sent every time just with different values, I was wondering if it could be possible to reload the screen every time new data comes in (preferably via a flag), that way I would have a live representation of the state of the data in the server.
If there is already a way to do this (maybe with the -x
command) please let me know.
thanks
When using under ubuntu system, the command 'wscat -c ws://echo.websocket.org' running correct. But when using in git bash under windows 7(64 bits) system, it shows "events.js:72 throw er; // Unhandled 'error' event ". Why is this?
What about integrating this under a flag? https://gist.github.com/jpmens/f4d8819b0d4a0821c0f3
The extraneous output (colors, >
and <
characters) makes it very hard to use this program with other programs that expect unmodified data from stdin and stdout:
$ wscat -c ws://localhost:8081/sync
connected (press CTRL+C to quit)
< 6
<���0"/�
+["55e06327e530a87a3f21f1f852681dc1","sync"]
>
This makes it difficult for me to take the data and feed it into another program. For example, here I've got forkdb running in the browser and I would like to sync that to a forkdb running on the server using just stdin and stdout but the line numbers, colors, status logging, and decoration gets in the way of that use case.
This is very un-like netcat, which just provides a raw undecorated stream on stdin and stdout.
In the mean time, I whipped up wsnc but I think it would be better for this package to remove decoration.
How can users specify a body, such as a JSON document, to include in the WebSocket request?
Just as a reminder, this project is a possible duplicate of wsd, except that it is written in Go.
If I run:
wscat -c ws://<address-to-my-websocket> -x 385
This will start a stream of gps positions for the specified unit. However after ca 32 seconds or 32 positions the stream stops.
However if I send the command manually:
wscat -c ws://<address-to-my-websocket>
> 385
The stream does not stop.
I need to send the first command automatically. Is there a way to fix so that the flag -x does not cause the stream to stop? Or another alternative to achieve the same result?
Firstly, thanks for your work.
Piped input doesn't work for me, please could you wait for a connection to process the input?
echo "hi!" | /usr/local/bin/wscat -c ws://echo.websocket.org
hi!
connected (press CTRL+C to quit)
>
Is there a way to send commands and pipe output (using -x for example flag in this case)?
wscat -c ws://localhost9222 -x "{"id": 1, "method": "Network.enable"}"
wscat -c ws://localhost9222 -x "{"id": 1, "method": "Page.navigate", "params" : {"url" : "http://www.github.com"}}" > out.log
Ideally, pass a command and somehow pipe output? Does this functionality already exist or is there an easy way to accomplish this?
I'm using wscat in a terminal with black background, and when blue is used, I can't see the text. In Vim, I can do set bg=dark to make the text colors lighter. There should be a way to change or disable the colors.
It would be cool if the client could implement a keep alive and have that be configurable as a command line option.
Solved - connect to ws://localhost:xxxx/socketcluster/
When attempting to connect to SocketCluster.io running on localhost, a 400 is returned.
Example:
wscat -c ws://127.0.0.1:8000
error: Error: unexpected server response (400)
Not sure if this is a problem with wscat or SC!
Hi im trying to connect like this : wscat -c wss://webgistesting.snig.gub.uy:8734/WebSocketsServer -p 13
However get this error: error: Error: unable to verify the first certificate
notably, for the client cert support. happy to do this for you if you add me to the project.
See websockets/ws#308.
Is there a way to disable SNI with wscat? I'm trying to mimic the behaviour of a remote device that does not support SNI and I want to see how AWS responds. If wscat already can do this, I'm not finding any documentation. If not, could it be added?
I'm not familiar with the SNI details but I have tried adding --host "", no effect - but I'm not sure --host is even SNI related.
Will binary messages be supported (ala wscat2
's -b
flag)?
It is a great tool and helpt me a lot~
while today I met a websocket application which need decompress.
so~I wish it can support gzip one day
i have install node npm after that install wscat. I try to connect it with localhost but it is not working.
// with localhost
wscat -c ws://localhost:8000
wscat -c ws://0.0.0.0:8000
// with local ip address
wscat -c ws://192.168.1.159:8000
wscat -c ws://127.0.0.1:8000
Geting same error
error: Error: connect ECONNREFUSED 127.0.0.1:8000
get same error
/var/www/html/index.js
var WebSocketServer = require('/usr/local/lib/node_modules/wscat').Server,
wss = new WebSocketServer({ port: 8888 });
wss.on('connection', function (connection) {
console.log("User connected");
connection.on('message', function (message) {
console.log("Got message:", message);
});
connection.send('Hello World');
});
If the server side keep pushing message to the client then the input cursor will jump to the beginning as soon as the new message arrive.
wscat --key server.key.pem --cert server.pem -c wss://127.0.0.1:8080
results in
(node:56311) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version. error: self signed certificate
Would be neat if wscat
could be configured to automatically send a pong
reply when receiving a ping
.
I'm getting the following error message. Tried it with wscat
installed through sudo apt install node-ws
and by cloning this repo. Both have the same result:
module.js:550
throw err;
^
Error: Cannot find module 'commander'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/user/wscat/bin/wscat:11:17)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
Sorry, some details:
nodejs --version
=> v8.16.1
I'm calling wscat against two different ports:
Simple node.js WebSocket Server:
wscat --connect ws://uri:8000
NGINX Proxy:
wscat --connect ws://uri:80
tcpdump
shows the following:
The header in the GET to the node server includes:
Connection: Upgrade
Upgrade: websocket
The header in the GET to the NGINX server only has:
Connection: keep-alive
Why would this happen?
➜ f git:(master) ✗ wscat -c wss://ws.foo.com/socket.io/?EIO=3&transport=websocket
[2] 12476
➜ f git:(master) ✗
[2] + 12476 suspended (tty output) wscat -c wss://ws.foo.com/socket.io/?EIO=3
➜ f git:(master) ✗ fg
[2] - 12476 continued wscat -c wss://ws.foo.com/socket.io/?EIO=3
error: Error: unexpected server response (502)
> %
Does not seem to be possible currently.
I just installed wscat
but:
$ wscat -c ws://localhost:8080/ws
/usr/local/lib/node_modules/wscat/node_modules/ws/lib/PerMessageDeflate.js:8
const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
^
TypeError: this is not a typed array.
at Function.from (native)
at Object.<anonymous> (/usr/local/lib/node_modules/wscat/node_modules/ws/lib/PerMessageDeflate.js:8:24)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/wscat/node_modules/ws/lib/WebSocket.js:16:27)
at Module._compile (module.js:410:26)
All invocations of wscat
ends this way.
IDK if this is of any importance:
$ npm version
{ npm: '3.5.2',
ares: '1.10.1-DEV',
http_parser: '2.5.0',
icu: '55.1',
modules: '46',
node: '4.2.6',
openssl: '1.0.2g-fips',
uv: '1.8.0',
v8: '4.5.103.35',
zlib: '1.2.8' }
I'm connecting to a service that sends ping messages to detect client disconnect. Because I'm not an Olympic gold medalist in typing, I can't finish writing a message before I get a ping. wscat prints "< Received ping" on the console, and moves my cursor to the beginning of the line. Ideally, it should stay where it was.
Closing a connection can also have a reason
string specified by a server, that tends to be useful when debugging some APIs.
Current behaviour of wscat is it only shows the closing code (the number), but not the reason string
I was trying to connect to a websocket using wscat and passing params through the query string. When passing one parameter, this worked successfully. But when trying to pass multiple parameters a connection request was never sent to the websocket.
This worked: wss://websocketurl.com?some_id=1234
This did not work: wss://websocketurl.com?some_id=1234&another_id=5678
Trying to pass multiple params in the query string printed out the following to the console on each subsequent attempt.
[1] 96022
[2] 96063
[3] 96070
[4] 97671
[5] 97674
This looks like maybe an incrementing id coming from wscat and a process id?
I'm not quite sure why that second query param is causing it to not attempt a connection.
Thanks for any help!
00e9a39 re-introduced websockets/ws#612 by overwriting the fix in 4de45ae
pi@RasPagerC9000PCBTest:~ $ wscat -c ws://echo.websocket.org
/usr/local/lib/node_modules/wscat/node_modules/ws/index.js:9
const WebSocket = require('./lib/WebSocket');
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/wscat/bin/wscat:17:17)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
pi@RasPagerC9000PCBTest:~ $
OS: Jessie lite
@lpinca, can you make me a contributor on this project?
Running https://www.websocket.org/echo.html I notice that the normal ws://
protocol connections do not work (anymore). I've also been unable to get the example in the README to work. Please, if this is the case, change to wss://
since that works out of the box.
Pings can get distracting, and maybe I'd like to copy the whole ws transcript without needing to worry about them.
Would also be a temporary fix to #84
I suggest -P
how to use self-signed certificate for access wss://
'-n' option looks just ignore SSL verification.
for example,
'curl' command can select specific certificate file by below example
curl --cacert ... --capath ...
It would be useful to have support for redirects like 3xx HTTP status like "-L" curl parameter.
I am using wscat to connect to a secure websocket with --no-check parameter and on server side i have asp.net core websocket listener. I can connect to websocket but wscat drops connection exactly after 1 minute with code 1006 and on server side there is exception of type WebSocketException with message - "The remote party closed the websocket connection without completing the close handshake" .
Seems like the connection closes immediately after invoking with the -x option?
passing -w
seems allows for arbitrarily specifying a wait time. Is there a way to keep open after -x ?
is there a way to configure an http proxy with wscat's cli ?
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Currently, the slash commands (/ping
, /pong
and /close
) are only usable in client mode. wscat does not try to use them in listen/server mode. It would be great if they were usable in listen mode too.
wscat is not sending \n
at the end of the lines. Add an option so all the input is send, including the new lines.
Colours should be used only in a terminal, and there should be an option to disable them too.
$ wscat --connect ws://somewhere | xxd | head
0000000: 1b5b 324b 1b5b 451b 5b33 326d 636f 6e6e .[2K.[E.[32mconn
0000010: 6563 7465 6420 2870 7265 7373 2043 5452 ected (press CTR
0000020: 4c2b 4320 746f 2071 7569 7429 1b5b 3339 L+C to quit).[39
0000030: 6d0a 3e20 1b5b 324b 1b5b 451b 5b33 346d m.> .[2K.[E.[34m
0000040: 3c20 7b22 7473 223a 3134 3738 3038 3537 < {"ts":14780857
0000050: 3139 2e38 392c 2264 6174 6122 3a5b 5b22 19.89,"data":[["
...
Please use isatty.
On the npm page https://www.npmjs.com/package/wscat the github link does not link to this repo.
This could be fixed by simply doing an npm release if i'm not mistaken?
Would help get a little more traction for the repo :)
Specifying a subprotocol via -s
(such as 'echo-protocol') no longer works.
Working as at release 2.1.0
Not working at release 2.2.0
Currently running release 2.10
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.