matyhtf / webim Goto Github PK
View Code? Open in Web Editor NEW使用PHP+Swoole实现的网页即时聊天工具
使用PHP+Swoole实现的网页即时聊天工具
PHP Notice: Undefined index: storage in /www/web/webim_baidu_com/public_html/src/Server.php on line 51
PHP Notice: Undefined offset: 2 in /www/web/webim_baidu_com/public_html/src/Server.php on line 197
PHP Warning: Swoole\Database\MySQLi SQL Error:
webim_history
order by webim_history
.id desc limit 100 webim_history
(name
,avatar
,msg
,type
) values('baidu','http://www.swoole.com/static/images/default.png','{\"cmd\":\"message\",\"from\":5,\"channal\":0,\"data\":\"\\u58eb\\u5927\\u592b\\u8bf4\\u7684\",\"type\":\"text\"}','text')如题
Notice: Use of undefined constant SWOOLE_PROCESS - assumed 'SWOOLE_PROCESS' in D
:\wamp\www\php-webim-master\webim_server.php on line 29
Call Stack:
0.0000 234304 1. {main}() D:\wamp\www\php-webim-master\webim_server.ph
p:0
Notice: Use of undefined constant SWOOLE_SOCK_TCP - assumed 'SWOOLE_SOCK_TCP' in
D:\wamp\www\php-webim-master\vendor\matyhtf\swoole_framework\libs\Swoole\Networ
k\Server.php on line 44
Call Stack:
0.0000 234304 1. {main}() D:\wamp\www\php-webim-master\webim_server.ph
p:0
0.0230 1473584 2. Swoole\Network\Server->__construct() D:\wamp\www\php-
webim-master\webim_server.php:29
Fatal error: Class 'swoole_server' not found in D:\wamp\www\php-webim-master\ven
dor\matyhtf\swoole_framework\libs\Swoole\Network\Server.php on line 45
Call Stack:
0.0000 234304 1. {main}() D:\wamp\www\php-webim-master\webim_server.ph
p:0
0.0230 1473584 2. Swoole\Network\Server->__construct() D:\wamp\www\php-
webim-master\webim_server.php:29
报错:Class 'Redis' not found in im/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Component/Redis.php:79,hiredis也已经装过了
一直报这个问题,想请教一下怎么解决呢
Swoole \ Exception \ NotFound
Swoole\Factory: resource[cache/session] not found.
看源码websocket服务器是基于swoole扩展提供的swoole_http_server用PHP实现的,是否可以改造成用swoole-1.7.9以后内置的swoole_websocket_server?这样websocket的帧解析、打包等字符串处理就可以交给效率高很多的C去处理,会提高不少性能
404 Not Found
Swoole\Factory: resource[cache/session] not found.
【历史记录】undefined对大家说:do
16:56:01
【历史记录】undefined对大家说:ataa
16:56:07
【历史记录】undefined对大家说:kaokao
16:57:11
【历史记录】undefined对大家说:kaokao
16:57:29
【历史记录】undefined对大家说:sdf
16:57:31
【历史记录】undefined对大家说:myqsadf
16:57:38
【历史记录】undefined对大家说:ppp
16:57:42
【历史记录】undefined对大家说:why
17:02:07
聊天记录文件里存的信息为
{"user":false,"msg":{"cmd":"message","from":1,"channal":0,"data":"do","type":"text"},"time":1440147361,"type":"text"}
{"user":false,"msg":{"cmd":"message","from":1,"channal":0,"data":"ataa","type":"text"},"time":1440147367,"type":"text"}
{"user":false,"msg":{"cmd":"message","from":2,"channal":0,"data":"kaokao","type":"text"},"time":1440147431,"type":"text"}
{"user":false,"msg":{"cmd":"message","from":3,"channal":0,"data":"kaokao","type":"text"},"time":1440147449,"type":"text"}
{"user":false,"msg":{"cmd":"message","from":3,"channal":0,"data":"sdf ","type":"text"},"time":1440147451,"type":"text"}
{"user":false,"msg":{"cmd":"message","from":2,"channal":0,"data":"myqsadf","type":"text"},"time":1440147458,"type":"text"}
{"user":false,"msg":{"cmd":"message","from":2,"channal":0,"data":"ppp","type":"text"},"time":1440147462,"type":"text"}
{"user":false,"msg":{"cmd":"message","from":4,"channal":0,"data":"why","type":"text"},"time":1440147727,"type":"text"}
一个新用户刚上去的时候聊天室友名字的,退出后,就全部变成undefined了
配置都是按文档来的,好郁闷
这个好像是扩展里面报的,没人遇到这个问题吗,求解决
访问http::// 180.76.128.198:8084 返回File not found.
这个是什么问题引起的?
nginx 配置如下
server {
listen 8084;
server_name 180.76.128.198;
index index.html index.php;
access_log /path/to/webim/webroot/access.log main;
error_log /path/to/webim/webroot/error.log warn;
location / {
root /path/to/webim/webroot;
proxy_set_header X-Real-IP $remote_addr;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php;
}
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
ERROR: The DSP swoole.dsp does not exist.
Can't inherit abstract function Swoole\IFace\Log::put() (previously declared abstract in Swoole\Log) in /var/www/sw_chat/vendor/matyhtf/swoole_framework/libs/Swoole/Log/FileLog.php on line 9
全部按说明来配置,打开后进入登录页面,然后一提交就跳到类似路径
http://im.swoole.com:8888/page/chatroom/?name=xxx .... 页面提示不存在
这是否使用的mvc框架路由,还是我弄错哪一步了?
PHP Notice: Undefined index: storage in /usr/local/src/webim/src/Server.php on line 51
PHP Fatal error: Uncaught Error: Class 'Redis' not found in /usr/local/src/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Component/Redis.php:79
Stack trace:
#0 /usr/local/src/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Component/Redis.php(72): Swoole\Component\Redis->connect()
#1 /usr/local/src/webim/vendor/matyhtf/swoole_framework/libs/factory/redis.php(25): Swoole\Component\Redis->__construct(Array)
#2 /usr/local/src/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Swoole.php(513): require('/usr/local/src/...')
#3 /usr/local/src/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Swoole.php(469): Swoole->loadModule('redis')
#4 /usr/local/src/webim/src/Storage.php(15): Swoole->__get('redis')
#5 /usr/local/src/webim/src/Server.php(51): WebIM\Storage->__construct(NULL)
#6 /usr/local/src/webim/webim_server.php(32): WebIM\Server->__construct(Array)
#7 /usr/local/src/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Network/Server.php(195): {closure}(Array)
#8 /usr/local/src/webim/webim_server.php(42): Swoole\Network\Ser in /usr/local/src/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Component/Redis.php on line 79
访问网站的时候出现 (连接已断开,请刷新页面重新登录。),出现闪退现在是怎么回事
PHP Fatal error: Cannot use 'String' as class name as it is reserved
Hi,刚接触swoole ,按照安装步骤。
php webim_server.php
PHP Warning: cli_set_process_title(): cli_set_process_title had an error: Not initialized correctly in /Users/xujiajun/myPlayground/php-webim/vendor/matyhtf/swoole_framework/libs/Swoole/Console.php on line 57
PHP Stack trace:
PHP 1. {main}() /Users/xujiajun/myPlayground/php-webim/webim_server.php:0
PHP 2. Swoole\Network\Server->run() /Users/xujiajun/myPlayground/php-webim/webim_server.php:31
PHP 3. swoole_server->start() /Users/xujiajun/myPlayground/php-webim/vendor/matyhtf/swoole_framework/libs/Swoole/Network/Server.php:214
PHP 4. Swoole\Network\Server->onMasterStart() /Users/xujiajun/myPlayground/php-webim/vendor/matyhtf/swoole_framework/libs/Swoole/Network/Server.php:214
PHP 5. Swoole\Console::setProcessName() /Users/xujiajun/myPlayground/php-webim/vendor/matyhtf/swoole_framework/libs/Swoole/Network/Server.php:140
PHP 6. cli_set_process_title() /Users/xujiajun/myPlayground/php-webim/vendor/matyhtf/swoole_framework/libs/Swoole/Console.php:57
Warning: cli_set_process_title(): cli_set_process_title had an error: Not initialized correctly in /Users/xujiajun/myPlayground/php-webim/vendor/matyhtf/swoole_framework/libs/Swoole/Console.php on line 57
翻过close 没有我的答案,逛过社区 日志 表示连接已经被关闭了,那又是什么原因?
[2015-09-25 20:43:34 *50585.0] WARN swFactoryProcess_finish: session#1 does not exist.
[2015-09-25 20:43:34 *50585.0] WARN swFactoryProcess_finish: session#1 does not exist.
[2015-09-25 20:43:38 *50585.0] swFactoryProcess_finish: session#1 does not exist.WARN
PS:我的环境:Mac OS X 10.10
望指点,感谢!
PHP Fatal error: Call to undefined function Swoole\Platform\posix_kill() in /home/php-webim/vendor/matyhtf/swoole_framework/libs/Swoole/Platform/Linux.php on line 8
运行
php webim_server.php start
Notice: Undefined index: storage in ~/webim/src/Server.php on line 51
PHP Fatal error: Uncaught Error: Class 'Redis' not found in ~/webim/vendor/matyhtf/swoole_framework/libs/Swoole/Component/Redis.php:83
求解是什么问题呢~
chat.js 里面有这个判断:
//使用flash websocket
else if (webim.flash_websocket)
{
WEB_SOCKET_SWF_LOCATION = "/static/flash-websocket/WebSocketMain.swf";
但是没找到在哪定义的webim.flash_websocket,所以flash_websocket一直无法使用
http://127.0.0.1:8888/main.html
我的配置如下
'127.0.0.1', //监听的端口 'port' => '9503', //WebSocket的URL地址,供浏览器使用的 'url' => 'ws://127.0.0.1:9503', //用于Comet跨域,必须设置为html所在的URL 'origin' => 'http://127.0.0.1:8888', ); $config['swoole'] = array( 'log_file' => **DIR**.'/log/swoole.log', 'worker_num' => 1, //不要修改这里 'max_request' => 0, 'task_worker_num' => 1, //是否要作为守护进程 'daemonize' => 0, ); $config['webim'] = array( //聊天记录存储的目录 'data_dir' => **DIR**.'/data/', 'log_file' => **DIR**.'/log/webim.log', ); return $config;配置完后,开启redis,在命令行运行 webim_server.php 和 flash_policy.php,浏览器访问webroot没什么反应
配置好后,浏览器运行:http://im.swoole.com出错,如下图
请问大神 @matyhtf 执行 php webim_server.php 的时候需要带上参数吗?我直接执行php webim_server.php或者带上参数 start,或者-p 或者-h,然后浏览器输入昵称和头像点击登录,提示说"服务器[ws://http://im.swoole.com:9503]拒绝连接",求指点
Uncaught RuntimeException: failed to connect mysql server. in /website/wwwroot/webim/src/Pool.php:26
我自己的mysql肯定没问题的,试过各种改configs/db就是死活报这个错
/**
* 使用文件或redis存储聊天信息
*/
$this->setStore(new \WebIM\Store\File($config['webim']['data_dir']));
$this->origin = $config['server']['origin'];
webroot下index.html不存在 客户端没法启用。
swoole.so已经加载好
swoole Version 1.8.5
swoole测试可用
web服务器使用 apache
php5.6
mac电脑上测试使用
src目录和README.md里介绍的目录内容不一致
oading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package matyhtf/swoole_framework dev-master exists as matyhtf/swoole_framework[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.1.1, 1.1.2, 1.10.0, 1.11.0, 1.11.1, 1.11.2, 1.12.0, 1.13.0, 1.13.1, 1.13.2, 1.13.3, 1.13.4, 1.13.5, 1.13.6, 1.14.0, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.2.0, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.3.0, 1.4.0, 1.5.0, 1.6.0, 1.6.1, 1.6.10, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.8.0, 1.8.1, 1.8.10, 1.8.11, 1.8.12, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8] but these are rejected by your constraint.
这个host IP如何填写? 我是在服务器上配置的
swoole已安装好
已运行 php webim_server.php start
环境:ubuntu14.04 php5.5 apache2
在浏览器中打开首页时报此错误,请问可能是哪些原因导致的?
PHP Fatal error: require(): Failed opening required '/var/www/swooleim/vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/swooleim/webim_server.php on line 5
各种各样的错误都有,可惜文档写的太简陋了。
Hi,
Im using cygwin for windows but i always get error like this.
$ /usr/sbin/httpd2-config
/usr/sbin/httpd2-config: line 20: /usr/sbin/apxs2: No such file or directory
/usr/sbin/httpd2-config: line 21: /usr/sbin/apxs2: No such file or directory
/usr/sbin/httpd2-config: line 22: /usr/sbin/apxs2: No such file or directory
chmod: cannot access '': No such file or directory
setfacl: No such file or directory
chmod: cannot access '': No such file or directory
setfacl: No such file or directory
*** Warning: The following function requires administrator privileges!
*** Query: Do you want to install httpd2 as service? (yes/no) yes
cygrunsrv: Given path doesn't point to a valid executable
Try `cygrunsrv --help' for more information.
Configuration finished. Have fun!
$ apt-cyg -m ftp://ftp.cygwinports.org/pub/cygwinports/ install apache2
Working directory is /setup
Mirror is ftp://ftp.cygwinports.org/pub/cygwinports/
--2016-04-13 16:22:31-- ftp://ftp.cygwinports.org/pub/cygwinports//x86_64/setup
.bz2
=> `.listing'
Resolving ftp.cygwinports.org (ftp.cygwinports.org)... 209.132.180.131
Connecting to ftp.cygwinports.org (ftp.cygwinports.org)|209.132.180.131|:21... c
onnected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /pub/cygwinports//x86_64 ... done.
==> PASV ... done. ==> LIST ... done.
.listing [ <=> ] 584 --.-KB/s in 0s
2016-04-13 16:22:38 (4.46 MB/s) - `.listing' saved [584]
Removed .listing'. --2016-04-13 16:22:38-- ftp://ftp.cygwinports.org/pub/cygwinports//x86_64/setup .bz2 =>
setup.bz2'
==> CWD not required.
==> PASV ... done. ==> RETR setup.bz2 ... done.
Length: 592838 (579K)
setup.bz2 100%[===================>] 578.94K 31.4KB/s in 35s
2016-04-13 16:23:14 (16.6 KB/s) - `setup.bz2' saved [592838]
Updated setup.ini
Package apache2 is already installed, skipping
在线体验地址看不了具体项目?
可不可以开多个聊天室,或者要如何操作?
thx!
composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
[2015-08-21 16:55:49 @36644.0] WARN swSocket_set_buffer_size#332: setsockopt(11, SOL_SOCKET, SO_SNDBUF, 8388608) failed. Error: No buffer space available[55].
[2015-08-21 16:57:23 *36646.0] WARN swFactoryProcess_finish: session#1 does not exist.
swoole
swoole support => enabled
Version => 2.0.7
Author => tianfeng.han[email: [email protected]]
kqueue => enabled
rwlock => enabled
async http/websocket client => enabled
pcre => enabled
zlib => 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.