之前部署過好幾個gatewayworker + thinkphp+ 第一次出現(xiàn)這種問題
1. (我只是一臺服務(wù)器 沒做分布式)
2. 第一次用阿里云服務(wù)器搭建
thinkphp bindUid的時候就提示
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 都沒問題
直接通過webscket聊天也沒問題
但是通過GatewayClient\Gateway就報錯 大佬們遇到過嗎
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://wtbis.cn/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use \Workerman\Worker;
use \GatewayWorker\Register;
// 自動加載類
require_once __DIR__ . '/../../vendor/autoload.php';
// register 必須是text協(xié)議
$register = new Register('text://0.0.0.0:1238');
// 如果不是在根目錄啟動,則運行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"); //這里不會報錯但是沒發(fā)送成功
Gateway::bindUid(Request::param('client_id'), 1);
return msg(Request::param('client_id'));
}
}
http://wtbis.cn/doc/gateway-worker/work-with-other-frameworks.html#%E5%85%B3%E4%BA%8EGatewayClient
手冊說如果GatewayClient和GatewayWorker不是在同一臺服務(wù)器上,則需要先將start_gateway.php中的lanIp改成當前服務(wù)器的內(nèi)網(wǎng)ip。看看是不是這個問題