Have anyone ever played these two things? Both of them can use the websocket protocol, and the onConnect of the workerman server has been executed, which indicates that the client and server can be connected. But why is the connection disconnected immediately? In addition, the server has not received a message from the client... Have anyone ever played with these two items? Both of them can use the websocket protocol,
In addition, the onConnect operation on the workerman server has been executed, indicating that the client and server can be connected.
But why is the connection disconnected immediately? In addition, the server does not receive the message sent by the client.
Workerman server code:
use Workerman\Worker;require_once '../Workerman/Autoloader.php';$worker = new Worker('websocket://0.0.0.0:8484');$ws_worker->count = 4;$worker->onConnect = function($connection){echo "new connection from ip " . $connection->getRemoteIp() . "\n";};$worker->onMessage = function($connection, $data){var_dump($data);$connection->send('receive success');};$worker->onError = function($connection, $code, $msg){echo "error $code $msg\n";};$worker->onBufferFull = function($connection){echo "bufferFull and do not send again\n";};$worker->onBufferDrain = function($connection){echo "buffer drain and continue send\n";};$worker->onClose = function($connection){echo "connection closed\n";};$worker->onWorkerStop = function($worker){echo "Worker stopping...\n";};$worker->onWorkerStart = function($worker){echo "Worker starting...\n";};
Client code: socket. io is used. This is an android application.
private Socket mSocket;{ try { mSocket = IO.socket("websocket://192.168.0.11:8484"); } catch (URISyntaxException e) {}}@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity1); mSocket.connect(); mSocket.emit("hello", "hello world"); mSocket.emit("emit something"); mSocket.send("send something"); mSocket.send("hello","thanks");}
Why is there a disconnection and the information is not received. This is the information received by the server.
new connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3
Reply content:
Have anyone ever played these two things? Both of them can use the websocket protocol,
In addition, the onConnect operation on the workerman server has been executed, indicating that the client and server can be connected.
But why is the connection disconnected immediately? In addition, the server does not receive the message sent by the client.
Workerman server code:
use Workerman\Worker;require_once '../Workerman/Autoloader.php';$worker = new Worker('websocket://0.0.0.0:8484');$ws_worker->count = 4;$worker->onConnect = function($connection){echo "new connection from ip " . $connection->getRemoteIp() . "\n";};$worker->onMessage = function($connection, $data){var_dump($data);$connection->send('receive success');};$worker->onError = function($connection, $code, $msg){echo "error $code $msg\n";};$worker->onBufferFull = function($connection){echo "bufferFull and do not send again\n";};$worker->onBufferDrain = function($connection){echo "buffer drain and continue send\n";};$worker->onClose = function($connection){echo "connection closed\n";};$worker->onWorkerStop = function($worker){echo "Worker stopping...\n";};$worker->onWorkerStart = function($worker){echo "Worker starting...\n";};
Client code: socket. io is used. This is an android application.
private Socket mSocket;{ try { mSocket = IO.socket("websocket://192.168.0.11:8484"); } catch (URISyntaxException e) {}}@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity1); mSocket.connect(); mSocket.emit("hello", "hello world"); mSocket.emit("emit something"); mSocket.send("send something"); mSocket.send("hello","thanks");}
Why is there a disconnection and the information is not received. This is the information received by the server.
new connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3connection closednew connection from ip 192.168.0.3
Https://github.com/walkor/phpsocket.io
The socket. io of the php version should also be based on workerman.
The socket. io client encapsulates its own protocol and cannot directly connect to workman?