ideawu / icomet Goto Github PK
View Code? Open in Web Editor NEWA C1000K comet/push server built with C++, for web and mobile app
License: BSD 3-Clause "New" or "Revised" License
A C1000K comet/push server built with C++, for web and mobile app
License: BSD 3-Clause "New" or "Revised" License
@DuoZhang developed an Android chat app that can be used with the web chat demo.
你好,我想请教一个问题,最近发现linux机器上的icomet-server 推送服务cpu过高,达到80%甚至90%,不知道是什么原因,通道也不多,每天大约800个左右,想问一下是什么原因?
能给个简单的事例吗,照你的方法好像不行
// this function is called in a separated thread, it gets called when receive msg from icomet server
//回调接口
size_t icomet_callback(char _ptr, size_t size, size_t nmemb, void *userdata)
{
const size_t sizeInBytes = size_nmemb;
NSData data = [[NSData alloc] initWithBytes:ptr length:sizeInBytes];
NSString s = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//开启主线程
dispatch_async(dispatch_get_main_queue(), ^
{
if([NSThread isMainThread])
{
NSLog(@"回到主线程");
}
[self setTextResult:s]; //这句话报self没有定义
});
return sizeInBytes;
}
按照示例,订阅的时候返回icomet_cb({type: "401", cname: "12", seq: "0", content: "Token Error"});
icomet-master/demo/web/chat.html?channel=channelname
icomet在重启后,seq就又从1开始了,客户这边如果用SEQ来判断消息的话会遗漏,怎么解决?
能不能让icomet在重启后发个消息什么 的,比如type ="restart"这样的标志
Project Link: https://github.com/DuoZhang/iCometClient4j
运行tools里的benchmark做测试 当sub大于248的时候
再用别的终端运行curl -v “url。。。”的时候返回recv failure:connection reset by peer
查看log也只是创建了248个连接(将cname固定的情况下就是一个channel有248个subs)
请问是否需要另外配置或者什么原因。
另外问一下:icomet是否能支持一个channel有上千甚至上万个subs。然后高频率的push消息(比如每秒推送一次或者两次)。场景大概就是实时发送股票指数到手机app终端
谢谢!
Centos 6.4/6.5 多次测试安装 demo文件不行接受到推送消息。
通过curl命令是可以的,很奇怪,这是为什么?
icomet自带的demo /web/chat.html
不知是我看错还是粗心
Server.cpp代码里面没发现有释放PresenceSubscriber
在Server::psub请求订阅通道事件消息, 连接断开在Server::psub_end未正常释放内存
Hi, guys!
Can you answer me, why in each message from server in Chrome console I get this message:
Resource interpreted as Script but transferred with MIME type text/html: "http://site.domain:8100/sub?cb=icomet_cb_0&cname=channel&seq=14&noop=5&token=&_=1431216336135&callback=cb"
And how I can fix it?
Thank you
ps. And can you told me, how I can hide information from http://site.domain:8100/sub?cb=icomet_cb_0&cname=channel&seq=1&noop=0&token=&_=1431217359932&callback=cb
Because if I open that link I see all messages in channel at current session
目前比较流行的即时推送协议XMPP和MQTT。请问下大牛你这个是基于那个协议的?
~
Can you specify the license for this project? (I would prefer 3-clause BSD, same as ssdb)
icomet 感觉使用非常的方便,针对需要有及时消息推送的项目足可以满足需求,我试用期间碰到一些问题总结分享一下:
"http://ip:port/stream?cname=c1&seq=1" 这个订阅API永远会返回当前频道中所有已存在的消息。
当时我的疑问是:
1:这些消息永远不会删除吗?(当消息非常多时,app第一次连接时要占用非常多的带宽)
2:有什么api可以删除过期的一些消息吗?(比如多少小时前的)
3:当空闲时这个api也会自动推送空消息,这个也有方法可以禁止吗?
后来资询了一下热情的作者,得到了回复:
1:默认保留最多10条,这个数字可以通过配置修改, 传seq=0就不会收到历史信息。
2:暂没有api删除过期的消息.
3:空闲时发空消息,这个是为了定期心跳,客户端可以用这个来判断server存活,可以修改配置延长。
另外几个概念要明确:
1:只有清空频道的说话,没有删除某条消息的概念。
以后再有使用经验继续补上,希望可以给没有能力读源代码的朋友参考。
但是如果顺序反过来的话,则sub无法获取到刚刚取得的消息。
最近在调研 icomet 和 nginx push stream 两个项目,
看到作者说 nginx push stream 的问题,但同时也看到国外的几个用 nginx push stream 的成功案例。
不知道 icomet 有没有经过验证的生产环境中的案例
I guess the memory consumption of icomet-server
should depend upon active connections
which is almost same in my usage, but with time (few days) it swells a lot. Relaunching the server fixes the issue, pls. see the image below - for same number of connections (active) it was using 1.1GB of RAM and restarting shrinked it to 33 MB!!!
是否可以增加全局推送,向所有频道发送消息
android的客户端实现是否耗电?
谢谢
Hello!
Can you tell me, whether it is possible to increase the time of token timeout?
By default, it afaik - 30 minutes.
Thank you!
希望增加某个频道的是否被订阅的的状态接口
Misc
icomet 源码分析
icomet如何群发消息(推送给所有人)
我现在发送消息是用php用curl来推送消息的
地址:http://127.0.0.1:8000/push?cname=".$cname."&content=".$content
请问icomet除了cname,content还有其他参数设置是可以推送给所有人的么,还是说要另外创建一条长连接,用户监听自己id的cname和all的cname,然后all就是推送给所有人??
请问有无更好的解决方案,不想挂两条长连接,怕占用太多进程。。。
Is there any future development roadmap for this?
e.g. image uploading/sending, cache expiration, download small images first before requesting big image download etc.
关注icomet好久了,有没有计划发布一版released版本?
如题
2015-07-03 11:17:09.632 [DEBUG] server.cpp(249): 127.0.0.1:42810 sub 44ab59c0ce2065692649b4a8907b2859, seq: 575, subs: 6
2015-07-03 11:17:09.637 [DEBUG] server.cpp(249): 127.0.0.1:42811 sub f46b7062c7005e9f, seq: 407, subs: 3
2015-07-03 11:17:09.638 [DEBUG] server.cpp(249): 127.0.0.1:42812 sub f46b7062c7005e9f, seq: 407, subs: 4
2015-07-03 11:17:09.642 [DEBUG] server.cpp(249): 127.0.0.1:42813 sub f46b7062c7005e9f, seq: 407, subs: 5
2015-07-03 11:17:09.646 [DEBUG] server.cpp(249): 127.0.0.1:42814 sub f46b7062c7005e9f, seq: 407, subs: 6
已经用content= URLEncoder.encode(content,"utf-8");设置过中文,
icomet4j 的源码部分也对应改了
mConn.setRequestProperty("Charset", "utf-8");
reader = new BufferedReader(new InputStreamReader(this.input, "utf-8"));
但是为啥收到的中文还是乱码呢。。。另外用js获取到的也是乱码
目的:客户端希望可以支持接收只针对自己的消息(独占一个频道,通过向频道发送消息),客户端希望可以接收某一频道的消息(与别人共同在一个频道,通过向频道发送消息),如何支持同时可以接收这两种消息(web端),如果同时2个长连接就没有意义了,求解决方案
This bug is in class HttpQuery
, the evkeyvalq is not freed by evhttp_clear_headers() after evhttp_parse_query().
Can I close connection from JavaScript ?
广播发送的消息 , 客户端接收不到
push的消息能接收到 , 最新master分支安装的
And, if you want follow EventSource, the out put must like this:
id: xxx \n
data: bla bla bla \n
\n\n
Hi guys, I want to ask you about existing Api for iComet for C++ (Qt predominantly) or other languages on which I can write code for desktop.
Thank you!
版本 0.2.3 安装失败
安装环境 Ubuntu 12.04
试了下版本 0.2.2可以
我发送的命令为:
curl -v "http://192.168.10.117:8000/push?cname=lingdu&content="{"from":"ss","id":"11"}""
接受的时候变成两个:
msg arrived: Message [type=data, cname=lingdu, seq=1, content=from:ss]
msg arrived: Message [type=data, cname=lingdu, seq=2, content=id:11]
Hello, does Icomet work with WebSocket, ?
What are the lybrary apis we can work with?
What are the javascript lybraries we can wrk with?
Do you have a scale benchmark simultaneous node connection and how many messages per second ?
What are the;
Scaling
Horizonal (multiple nodes) and Vertical scaling?
Regards, Heather
icomet支持websocket吗?
我看wiki上写
content must be json encoded string without leading quote and trailing quote.
我用以下的路径去访问都有问题。
http://IP:8000/push?cname=test&content="uid":"1","content":"111111"
http://IP:8000/push?cname=test&content=uid:1,content:111111
http://IP:8000/push?cname=test&content={"uid":"1","content":"111111"}
http://IP:8000/push?cname=test&content={uid:1,content:111111}
RT,求教,我看logs/log.txt
全部是debug信息,这种问题如何排查呢?会不会是内存不够导致死掉了呢?我的内存比较的低
【log信息:】
2014-07-10 12:11:40.340 [DEBUG] server.cpp(241): 218.58.77.117:4323 sub result, seq: 6, subs: 10
2014-07-10 12:11:40.450 [DEBUG] server.cpp(185): 218.17.150.249:50810 sub_end result, subs: 9,
2014-07-10 12:11:40.453 [DEBUG] server.cpp(241): 218.75.66.130:54719 sub result, seq: 6, subs: 10
2014-07-10 12:11:40.552 [DEBUG] server.cpp(241): 183.14.109.91:32358 sub result, seq: 6, subs: 11
2014-07-10 12:11:40.602 [DEBUG] server.cpp(241): 123.97.237.85:2178 sub schedule, seq: 6, subs: 23
2014-07-10 12:11:41.084 [DEBUG] server.cpp(241): 60.161.97.33:28789 sub result, seq: 6, subs: 12
2014-07-10 12:11:41.109 [DEBUG] server.cpp(241): 218.94.115.131:11256 sub result, seq: 6, subs: 13
2014-07-10 12:11:41.269 [DEBUG] server.cpp(241): 58.250.109.83:37121 sub result, seq: 6, subs: 14
2014-07-10 12:11:41.290 [DEBUG] server.cpp(241): 183.14.109.91:13882 sub result, seq: 6, subs: 15
2014-07-10 12:11:41.450 [DEBUG] server.cpp(185): 183.62.51.195:52533 sub_end schedule, subs: 22,
2014-07-10 12:11:41.450 [DEBUG] server.cpp(185): 115.238.84.134:53042 sub_end result, subs: 14,
2014-07-10 12:11:41.579 [DEBUG] server.cpp(241): 123.97.237.85:2177 sub result, seq: 6, subs: 15
2014-07-10 12:11:41.672 [DEBUG] server.cpp(241): 120.40.4.70:11566 sub result, seq: 6, subs: 16
2014-07-10 12:11:42.019 [DEBUG] server.cpp(241): 218.17.150.249:50810 sub result, seq: 6, subs: 17
2014-07-10 12:11:42.092 [DEBUG] server.cpp(241): 218.94.115.131:10960 sub result, seq: 6, subs: 18
2014-07-10 12:11:42.200 [DEBUG] server.cpp(241): 27.38.66.236:59911 sub result, seq: 6, subs: 19
2014-07-10 12:11:42.364 [DEBUG] server.cpp(241): 58.210.35.50:4563 sub result, seq: 6, subs: 20
2014-07-10 12:11:42.389 [DEBUG] server.cpp(241): 223.104.4.55:52907 sub result, seq: 6, subs: 21
2014-07-10 12:11:42.944 [DEBUG] server.cpp(241): 183.62.51.195:52533 sub schedule, seq: 0,
【free信息】
[root@hkdmall logs]# free -m
total used free shared buffers cached
Mem: 1024 1014 9 0 0 3
-/+ buffers/cache: 1010 13
Swap: 2048 1859 188
【top信息】
top - 12:13:05 up 14 days, 23:25, 2 users, load average: 1.12, 4.88, 4.98
Tasks: 24 total, 1 running, 23 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.1%us, 4.3%sy, 0.0%ni, 89.4%id, 0.0%wa, 0.0%hi, 0.0%si, 4.3%st
Mem: 1048576k total, 1041424k used, 7152k free, 0k buffers
Swap: 2097152k total, 1902612k used, 194540k free, 4704k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
17914 root 20 0 12.3g 1.8g 1704 S 53.8 182.7 17:54.17 java
1236 www 20 0 64068 20m 124 S 0.0 2.0 0:51.50 nginx
1237 www 20 0 63476 19m 72 S 0.0 1.9 0:25.77 nginx
24932 root 20 0 84364 11m 196 S 7.7 1.1 3:54.95 memcached
29613 root 20 0 456m 10m 2396 S 0.0 1.0 4:01.80 mysqld
6301 root 20 0 12632 1212 956 R 0.0 0.1 0:00.01 top
4480 root 20 0 86512 1092 424 S 0.0 0.1 0:00.44 sshd
4630 root 20 0 24344 944 536 D 0.0 0.1 0:02.66 comet-server
icomet有ios方面的客户端sdk吗,现在想用在iphone上,请问有什么好的建议?
我启用了10个chat
这些问题大家都碰到过没有,如果有的话,麻烦告知我一下是如何解决的,感谢
Too many subscribers,您好icomet使用过您的这个产品,但是今天出现了太多的订阅者,这个不知道是否有地方可以配置。
16:18:43 icomet[0] resp Object {type: "429", cname: "result", seq: 0, content: "Too many subscribers"} icomet.js:296
16:18:46 icomet[1] sub icomet.js:294
Resource interpreted as Script but transferred with MIME type text/html: "http://192.80.133.190:8100/sub?cb=icomet_cb_1&cname=schedule&seq=0&noop=0&token=&_=1404893926813&callback=cb". jquery-1.8.2.js:8304
16:18:47 icomet[1] resp Object {type: "429", cname: "schedule", seq: 0, content: "Too many subscribers"} icomet.js:296
16:18:49 icomet[0] sub icomet.js:294
Resource interpreted as Script but transferred with MIME type text/html: "http://192.80.133.190:8100/sub?cb=icomet_cb_0&cname=result&seq=0&noop=0&token=&_=1404893929922&callback=cb&_=1404893929922". jquery-1.8.2.js:8304
16:18:50 icomet[0] resp Object {type: "429", cname: "result", seq: 0, content: "Too many subscribers"}
// this function is called in a separated thread, it gets called when receive msg from icomet server
//回调接口
size_t icomet_callback(char _ptr, size_t size, size_t nmemb, void *userdata)
{
const size_t sizeInBytes = size_nmemb;
NSData data = [[NSData alloc] initWithBytes:ptr length:sizeInBytes];
NSString s = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"返回结果:%@", s);
//这里为什么调用不了UIViewController里的其他方法
return sizeInBytes;
}
reads.la -lz ../libevent_openssl.la -lssl -lcrypto -lrt
libtool: link: gcc -g -O2 -Wall -fno-strict-aliasing -pthread -pthread -o .libs/regress regress-regress.o regress-regress_buffer.o regress-regress_http.o regress-regress_dns.o regress-regress_testutils.o regress-regress_rpc.o regress-regress.gen.o regress-regress_et.o regress-regress_bufferevent.o regress-regress_listener.o regress-regress_util.o regress-tinytest.o regress-regress_main.o regress-regress_minheap.o regress-regress_thread.o regress-regress_zlib.o regress-regress_ssl.o ../.libs/libevent.so ../.libs/libevent_pthreads.so -lz ../.libs/libevent_openssl.so -lssl -lcrypto -lrt -pthread
make[3]: Leaving directory /data/soft/icomet/deps/libevent-2.0.21-stable/test' make[2]: Leaving directory
/data/soft/icomet/deps/libevent-2.0.21-stable/test'
make[1]: Leaving directory /data/soft/icomet/deps/libevent-2.0.21-stable' build.sh: 76: build.sh: [[: not found build.sh: 100: build.sh: [[: not found cd src/util; make make[1]: Entering directory
/data/soft/icomet/src/util'
g++ -c -g -O2 -Wall -Wno-sign-compare -I "/data/soft/icomet/deps/libevent-2.0.21-stable" -I "/data/soft/icomet/deps/libevent-2.0.21-stable/include" -I "/data/soft/icomet/deps/libevent-2.0.21-stable/compact" -I "/data/soft/icomet/deps/jemalloc-3.4.0/include" log.cpp
g++ -c -g -O2 -Wall -Wno-sign-compare -I "/data/soft/icomet/deps/libevent-2.0.21-stable" -I "/data/soft/icomet/deps/libevent-2.0.21-stable/include" -I "/data/soft/icomet/deps/libevent-2.0.21-stable/compact" -I "/data/soft/icomet/deps/jemalloc-3.4.0/include" config.cpp
In file included from config.cpp:3:0:
strings.h: In function 'std::string int64_to_str(int64_t)':
strings.h:133:43: warning: format '%lld' expects argument of type 'long long int', but argument 4 has type 'int64_t {aka long int}' [-Wformat]
strings.h:133:43: warning: format '%lld' expects argument of type 'long long int', but argument 4 has type 'int64_t {aka long int}' [-Wformat]
strings.h: In function 'std::string uint64_to_str(uint64_t)':
strings.h:145:43: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64_t {aka long unsigned int}' [-Wformat]
strings.h:145:43: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64_t {aka long unsigned int}' [-Wformat]
strings.h: In function 'int parse_ip_port(const char_, std::string_, int_)':
strings.h:167:30: error: invalid conversion from 'const char_' to 'char_' [-fpermissive]
make[1]: *_* [config.o] Error 1
make[1]: Leaving directory `/data/soft/icomet/src/util'
make: *** [all] Error 2
看了icomet_demo貌似还有不少疑问,不过完成一个项目是没有问题了
是否可以完善下文档相关参数说明(比如:自定义一些参数的规则(传参field))。毕竟不是C++的人员
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.