使用 postman new api 测试 websocket

alt*_*ios 1 javascript testing websocket postman

我正在尝试让 websockets 的邮递员 api 正常工作,但是我什至无法建立连接:

当我尝试建立连接时

ws://localhost:5001/socket.io/

Run Code Online (Sandbox Code Playgroud)

结果是:

Error: Unexpected server response: 400 //for ws
Run Code Online (Sandbox Code Playgroud)
ws://localhost:5001/socket.io/

Run Code Online (Sandbox Code Playgroud)

连接到 socket.io/express/nodejs 服务器的正确 url 字符串是什么?

Udi*_*dit 5

Socket.io 支持pollingwebsocket 传输.

要连接 Postman 的 WebSocket 客户端,我们必须在连接到 Socket.io 服务器时显式设置 WebSocket 传输。transport=websocket这可以通过设置连接 URL 中的参数来完成。

在你的情况下,它将是:ws://localhost:5001/socket.io/?transport=websocket