服务器上开启一个websocket,本地测试连接,报错

0

报错内容:
WebSocket connection to 'ws://58.247.98.146:17000/' failed: Error during WebSocket handshake: net::ERR_INVALID_HTTP_RESPONSE
 
服务器workerman开启websocket:


use Workerman\Worker;
use Workerman\Lib\Timer;
use Workerman\connection\AsyncUdpConnection;
require_once 'Workerman-master/Autoloader.php';
require_once 'Workerman-master/mysql_master/src/Connection.php';

require_once 'common.php';

$worker = new Worker("websocket://0.0.0.0:70000");

$worker->name = "worker";

$worker->onWorkerStart = function ($worker) {
};

//当收到用户发送的信息时
$worker->onMessage = function ($connection, $data) use ($worker) {
$connection->send($data);

};

 html/js:


<script>
var ws = new WebSocket('ws://58.247.98.146:17000');
ws.onopen = function(){
var uid = 'uid1';
ws.send(uid);
};
ws.onmessage = function(e){
alert(e.data);
};
</script>
已邀请:

静默

赞同来自: 守护

连错端口了,17000和70000是有区别的 - -!

守护

赞同来自:

可以连接上了,非常感谢!

要回复问题请先登录注册