之前部署過(guò)好幾個(gè)gatewayworker + thinkphp+ 第一次出現(xiàn)這種問(wèn)題
1. (我只是一臺(tái)服務(wù)器 沒(méi)做分布式)
2. 第一次用阿里云服務(wù)器搭建
thinkphp bindUid的時(shí)候就提示
stream_socket_client(): unable to connect to tcp://127.0.0.1:29** (Connection refused)
php start.php status
php start.php start
php start.php start -d 都沒(méi)問(wèn)題
直接通過(guò)webscket聊天也沒(méi)問(wèn)題
但是通過(guò)GatewayClient\Gateway就報(bào)錯(cuò) 大佬們遇到過(guò)嗎
start_register.php:
<?php
/**
* This file is part of workerman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://m.wtbis.cn/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use \Workerman\Worker;
use \GatewayWorker\Register;
// 自動(dòng)加載類
require_once __DIR__ . '/../../vendor/autoload.php';
// register 必須是text協(xié)議
$register = new Register('text://0.0.0.0:1238');
// 如果不是在根目錄啟動(dòng),則運(yùn)行runAll方法
if(!defined('GLOBAL_START'))
{
Worker::runAll();
}
thinkphp
<?php
namespace app\api\controller;
use app\api\service\file\UploadService;
use app\api\service\user\UserLogService;
use app\api\service\user\UserService;
use GatewayClient\Gateway;
use think\facade\Request;
class User extends Base
{
public function bind()
{
Gateway::$registerAddress = "127.0.0.1:1238";
Gateway::sendToAll("11111"); //這里不會(huì)報(bào)錯(cuò)但是沒(méi)發(fā)送成功
Gateway::bindUid(Request::param('client_id'), 1);
return msg(Request::param('client_id'));
}
}
http://m.wtbis.cn/doc/gateway-worker/work-with-other-frameworks.html#%E5%85%B3%E4%BA%8EGatewayClient
手冊(cè)說(shuō)如果GatewayClient和GatewayWorker不是在同一臺(tái)服務(wù)器上,則需要先將start_gateway.php中的lanIp改成當(dāng)前服務(wù)器的內(nèi)網(wǎng)ip??纯词遣皇沁@個(gè)問(wèn)題