Socket. io and workerman Problems

Source: Internet
Author: User
Tags autoloader
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.