it always auto disconnect from server(use php swoole)
See original GitHub issuei had read the document, but i can’t find the answer, so i write this question for need help;
Note: for support questions, please use one of these channels: stackoverflow or slack
You want to:
- report a bug
- request a feature
- need help
Current behaviour
auto disconnect from server
Steps to reproduce (if the current behaviour is a bug)
client code: `var socket = io(‘127.0.0.1:9502’, { transports: [‘websocket’], });
socket.connect(); socket.on(‘connect’, function(){ socket.send(‘Hello, i am HMM’); console.log(‘Connected to server’); }); ` server code:
`$ws = new swoole_websocket_server(‘0.0.0.0’, 9502);
$ws->on(‘open’, function(swoole_websocket_server $server, $request) { echo “Open\n”; $server->push($request->fd, “hello, welcome\n”); });
$ws->on(‘message’, function($server, $request) { echo “Message: {$request->data}\n”; $server->push($request->fd, “server:{$request->data}”); });
$ws->on(‘close’, function($server, $fd) { echo “client-{$fd} is closed\n”; });
$ws->start(); ` step1: run server php server.php step2: run client open the html page on the browser; step3: get infomation from server Open client-1 is closed Open client-2 is closed Open client-3 is closed Open client-4 is closed Open client-5 is closed Open client-6 is closed … Note: the best way to get a quick answer is to provide a failing test case, by forking the following fiddle for example.
Expected behaviour
keep alive
Setup
- OS: ubuntu 16.4 (64-bit)
- browser: firefox 54.0
- socket.io version: v2.0.3
Other information (e.g. stacktraces, related issues, suggestions how to fix)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Thanks. If i use the native websocket, it’s work!
var socket = new WebSocket('ws://localhost:9502'); socket.send('Hello');
I will receive a message from terminal: Message: Hello And i don’t know socketio how to work. i will check it agin.Hi! I don’t know the Swoole project, is it supposed to be compatible with the socket.io client?