Git Product home page Git Product logo

brewlin / swoole-im Goto Github PK

View Code? Open in Web Editor NEW
142.0 3.0 41.0 1.14 MB

基于swoole开发的在线聊天平台,前端集成layerim框架,swoole基于eayswoole框架,异步连接池,多进程,异步任务,独立httperserver api,websocket推送,重构使用swoft-cloud 进行微服务架构

Home Page: http://im.brewlin.com

PHP 75.56% HTML 24.43% Makefile 0.01%
swoole php7 websocket im httpserver easyswoole api restful cli async-redis

swoole-im's Introduction

Hi there 👋

swoole-im's People

Contributors

brewlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swoole-im's Issues

nginx +swoole 配置端口转发不成功,求指点

想让项目跑起来,于是按照步骤进行安装,但是启动服务失败,nginx配置也查了各种资料还是不行,请指教

php版本

[root@VM_0_15_centos im]# php -v
PHP 7.2.14 (cli) (built: Jan 29 2019 12:00:38) ( NTS )

php扩展:
[root@VM_0_15_centos im]# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
swoole
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zlib

swoole配置:

[root@VM_0_15_centos im]# php --ri swoole

swoole

swoole support => enabled
Version => 2.0.8
Author => tianfeng.han[email: [email protected]]
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled

Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

项目目录:

[root@VM_0_15_centos im]# ls
App            composer.lock  Config.php           easyswoole.install  index.php  makefile   RedisKeys.txt  Temp
composer.json  Conf           EasySwooleEvent.php  img                 Log        README.md  talk.sql       vendor

Config.php 配置:

<?php
/**
 * Created by PhpStorm.
 * User: yf
 * Date: 2017/12/30
 * Time: 下午10:59
 */

return [
    'MAIN_SERVER'=>[
        'HOST'=>'0.0.0.0',
        'PORT'=>9501,
        'SERVER_TYPE'=>\EasySwoole\Core\Swoole\ServerManager::TYPE_WEB_SOCKET_SERVER,
        'SOCK_TYPE'=>SWOOLE_TCP,//该配置项当为SERVER_TYPE值为TYPE_SERVER时有效
        'RUN_MODEL'=>SWOOLE_PROCESS,
        'SETTING'=>[
            'task_worker_num' => 2, //异步任务进程
            'task_max_request'=>10,
            'max_request'=>2500,//强烈建议设置此配置项
            'worker_num'=>2,
            'document_root' => '/website/swoole-im/Public',  // 静态资源目录
            'enable_static_handler' => true,
//            'heartbeat_idle_time' => 60,
//            'heartbeat_check_interval' => 20,
        ],
    ],
    'DEBUG'=>true,
    'TEMP_DIR'=>EASYSWOOLE_ROOT.'/Temp',
    'LOG_DIR'=>EASYSWOOLE_ROOT.'/Log',
    'EASY_CACHE'=>[
        'PROCESS_NUM'=>3,//若不希望开启,则设置为0
        'PERSISTENT_TIME'=>5//如果需要定时数据落地,请设置对应的时间周期,单位为秒
    ],
    'CLUSTER'=>[
        'enable'=>false,
        'token'=>null,
        'broadcastAddress'=>['255.255.255.255:9556'],
        'listenAddress'=>'0.0.0.0',
        'listenPort'=>9556,
        'broadcastTTL'=>5,
        'serviceTTL'=>10,
        'serverName'=>'easySwoole',
        'serverId'=>null
    ],
    'MYSQL'=>[
        'HOST'=>'隐藏一下',
        'USER'=>'隐藏一下',
        'PASSWORD'=>'隐藏一下',
        'DB_NAME'=>'talk'
    ],

    'REDIS' => [
        'host' => '隐藏一下', // redis主机地址
        'port' => 6379, // 端口
        'serialize' => false, // 是否序列化php变量
        'auth' => '隐藏一下', // 密码
        'pool' => [
            'min' => 5, // 最小连接数
            'max' => 100 // 最大连接数
        ],
        'errorHandler' => function(){
            return null;
        }
    ],

    'database' => [
        // 数据库类型
        'type'            => 'mysql',
        // 服务器地址
        'hostname'        => '隐藏一下',
        // 数据库名
        'database'        => 'talk',
        // 用户名
        'username'        => '隐藏一下',
        // 密码
        'password'        => '隐藏一下',
        // 端口
        'hostport'        => '3306',
        // 数据库表前缀
        'prefix'          => '',
        // 是否需要断线重连
        'break_reconnect' => true,
    ],

    'setting' => [
        'token_salt' => 'gye76qwei23eq',
        'WebSocketControllerPath' => 'App\WebsocketController\\',
        'cache_name' => [
            'token_user' => 'user:token:%s:data',                           //  token   => user 信息, 用户登录时创建
            'number_userOtherInfo' =>'userOtherInfo:%s:number:data',        //  number  => fd,token 等信息,用户登录时创建
            'fd_token' => 'fd:%s:data',                                     //  fd => token,    用户登录时创建
            'friend_req' => 'friend:fromNumber:%s:data',                    //  from_num => to_num,发送好友请求时创建,对方拒绝或同意时销毁
            'group_number_fd' => 'group:number:%s:data',                    //  gnumber => fds,创建新群组时创建
        ],
    ]
];

nginx 配置:

server{
        listen 80;
        server_name im.itsideline.com;

        location / {
                root /home/www/im;
                index index.html index.htm index.php;
                if (!-e $request_filename) {
                        proxy_pass http://127.0.0.1:9501;
                }
        }
}

开启服务报错:

[root@VM_0_15_centos im]# php index.php start
  ______                          _____                              _
 |  ____|                        / ____|                            | |
 | |__      __ _   ___   _   _  | (___   __      __   ___     ___   | |   ___
 |  __|    / _` | / __| | | | |  \___ \  \ \ /\ / /  / _ \   / _ \  | |  / _ \
 | |____  | (_| | \__ \ | |_| |  ____) |  \ V  V /  | (_) | | (_) | | | |  __/
 |______|  \__,_| |___/  \__, | |_____/    \_/\_/    \___/   \___/  |_|  \___|
                          __/ |
                         |___/

EasySwoole framework Version 2.0.2

listen address      0.0.0.0
listen port         9501
worker num          2
task worker num     2
run at user         root
daemonize           false
debug enable        true
swoole version      2.0.8
swoole pid          21696
loading data from file at process easySwoole_Cache_Process_0
loading data from file success at process easySwoole_Cache_Process_0
loading data from file at process easySwoole_Cache_Process_1
loading data from file success at process easySwoole_Cache_Process_1
loading data from file at process easySwoole_Cache_Process_2
loading data from file success at process easySwoole_Cache_Process_2
PHP Fatal error:  Uncaught Error: Call to a member function getObj() on null in /home/www/im/App/Service/RedisPoolService.php:23
Stack trace:
#0 /home/www/im/App/Service/UserCacheService.php(142): App\Service\RedisPoolService->__construct()
#1 /home/www/im/App/Sock/Parser/OnClose.php(80): App\Service\UserCacheService::getTokenByFd(1)
#2 /home/www/im/App/Sock/Parser/OnClose.php(28): App\Sock\Parser\OnClose->getInfoByFd()
#3 /home/www/im/EasySwooleEvent.php(75): App\Sock\Parser\OnClose->close()
#4 [internal function]: EasySwoole\EasySwooleEvent::EasySwoole\{closure}(Object(Swoole\WebSocket\Server), 1, -1)
#5 /home/www/im/vendor/easyswoole/easyswoole/src/Core/Component/Invoker.php(56): Swoole\Coroutine::call_user_func_array(Object(Closure), Array)
#6 /home/www/im/vendor/easyswoole/easyswoole/src/Core/Swoole/ServerManager.php(137): EasySwoole\Core\Component\Invoker::callUserFuncArray(Object(Closure), Array)
#7 [internal function]: EasySwoole\Core\Swoole\ServerManager->EasySwoole\Core\Swoole\{closure}(Object(Swoole\WebSocket\Server in /home/www/im/App/Service/RedisPoolService.php on line 23

访问域名也会包502 ...
请问这该如何进行了...

php index.php start 启动失败,下面是最严重的错误

Fatal error: Uncaught Error: Class 'EasySwoole\Core\Swoole\Coroutine\Redis' not found in /home/wwwroot/default/swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/Coroutine/Client/Redis.php:30
Stack trace:
#0 /home/wwwroot/default/swoole-im-master/App/Utility/RedisPool.php(25): EasySwoole\Core\Swoole\Coroutine\Client\Redis->__construct('127.0.0.1', 6379, false, NULL)
#1 /home/wwwroot/default/swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/Coroutine/AbstractInterface/CoroutinePool.php(29): App\Utility\RedisPool->createObject()
#2 /home/wwwroot/default/swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/Coroutine/PoolManager.php(75): EasySwoole\Core\Swoole\Coroutine\AbstractInterface\CoroutinePool->__construct(3, 10)
#3 /home/wwwroot/default/swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/Coroutine/PoolManager.php(110): EasySwoole\Core\Swoole\Coroutine\PoolManager->init('App\Utility\Red...')
#4 /home/wwwroot/default/swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoo in /home/wwwroot/default/swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/Coroutine/Client/Redis.php on line 30
PHP Fatal error: Uncaught Error: Class 'EasySwoole\Core\Swoole\Coroutine\Redis' not found in /home/wwwroot/default/swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/Coroutine/Client/Redis.php:30

不再维护了吗?

不再维护更新了吗?

运行不起来。
图省事,使用的宝塔面板安装的 redis 和 swoole 扩展。
PHP 版本用的7.4

php7.4启动报错

Error at file[swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Component/Invoker.php] line[56] message:[Uncaught Error: Call to undefined method Swoole\Coroutine::call_user_func_array() in swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Component/Invoker.php:56
Stack trace:
#0 swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/ServerManager.php(137): EasySwoole\Core\Component\Invoker::callUserFuncArray(Object(Closure), Array)
#1 {main}
thrown]
22-08-23 11:24:27:Error at file[swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Component/Invoker.php] line[56] message:[Uncaught Error: Call to undefined method Swoole\Coroutine::call_user_func_array() in swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Component/Invoker.php:56
Stack trace:
#0 swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/ServerManager.php(137): EasySwoole\Core\Component\Invoker::callUserFuncArray(Object(Closure), Array)
#1 {main}
thrown]
22-08-23 11:24:27:Error at file[Unknown] line[0] message:[Swoole\Event::rshutdown(): Event::wait() in shutdown function is deprecated]
22-08-23 11:24:27:Error at file[swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Component/Cache/CacheProcess.php] line[153] message:[Uncaught Error: Class 'swoole_serialize' not found in swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Component/Cache/CacheProcess.php:153
Stack trace:
#0 swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Component/Cache/CacheProcess.php(39): EasySwoole\Core\Component\Cache\CacheProcess->loadData()
#1 swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/Process/AbstractProcess.php(102): EasySwoole\Core\Component\Cache\CacheProcess->run(Object(Swoole\Process))
#2 [internal function]: EasySwoole\Core\Swoole\Process\AbstractProcess->__start(Object(Swoole\Process))
#3 swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Swoole/ServerManager.php(67): Swoole\Server->start()
#4 swoole-im-master/vendor/easyswoole/easyswoole/src/Core/Core.php(45): EasySwoole\Core\Swoole\ServerManager->start()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.