我看到有一个 websocket 端点可以通过 Java 测试计算出鳍。在日志中我看到了
Connecting to: ws://127.0.0.1:8080/76f48a44-0af8-444c-ba97-3f1ed34afc91/tweets
就像任何其他 REST
API 一样,我想通过浏览器或 curl 访问它,但是当我这样做时,我看到了
➜ tweetstream git:(master) ✗ curl ws://127.0.0.1:8080/b9b90525-4cd4-43de-b893-7ef107ad06c2/tweets
curl: (1) Protocol ws not supported or disabled in libcurl
和
➜ tweetstream git:(master) ✗ curl http://127.0.0.1:8080/b9b90525-4cd4-43de-b893-7ef107ad06c2/tweets
<html><head><title>Error</title></head><body>Not Found</body></html>%
有没有办法用浏览器/curl 测试 websocket API?
最佳答案
这对我有用:
$ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: echo.websocket.org" -H "Origin: http://www.websocket.org" http://echo.websocket.org
来自:http://www.thenerdary.net/post/24889968081/debugging-websockets-with-curl
关于javascript - 如何命中 WebSocket 端点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24704097/