websocket服务器无响应,WebSocket服务器因某些原因无法正常工作(WebSocket server not working for some reasons)...

WebSocket服务器因某些原因无法正常工作(WebSocket server not working for some reasons)

我尝试使用ws创建一个非常简单的服务器,当我运行服务器node index.js并且我在我的浏览器中午餐localhost:8080时,我的控制台中没有任何内容。

我应该看到client connected on localhost:8080打印到控制台

-index.js

const WebSocketServer = require('ws').Server;

const wss = new WebSocketServer({port: 8080});

const onConnect = wss => console.log('client connected on localhost:8080');

Rx.Observable

.fromEvent(wss, 'connection')

.subscribe(onConnect);

I tried to create a very simple server using ws, When i run the server node index.js and i lunch localhost:8080 in my browser nothing appear in my console.

i should see client connected on localhost:8080 printed to the console

-index.js

const WebSocketServer = require('ws').Server;

const wss = new WebSocketServer({port:

你可能感兴趣的:(websocket服务器无响应)