cppcms-users Mailing List for CppCMS C++ Web Framework (Page 39)
Brought to you by:
artyom-beilis
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
(22) |
Mar
|
Apr
(3) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
(16) |
Dec
(13) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(4) |
Feb
|
Mar
(8) |
Apr
(8) |
May
(8) |
Jun
(36) |
Jul
(63) |
Aug
(126) |
Sep
(47) |
Oct
(66) |
Nov
(46) |
Dec
(42) |
| 2011 |
Jan
(87) |
Feb
(24) |
Mar
(54) |
Apr
(21) |
May
(22) |
Jun
(18) |
Jul
(22) |
Aug
(101) |
Sep
(57) |
Oct
(33) |
Nov
(34) |
Dec
(66) |
| 2012 |
Jan
(64) |
Feb
(76) |
Mar
(73) |
Apr
(105) |
May
(93) |
Jun
(83) |
Jul
(84) |
Aug
(88) |
Sep
(57) |
Oct
(59) |
Nov
(35) |
Dec
(49) |
| 2013 |
Jan
(67) |
Feb
(17) |
Mar
(49) |
Apr
(64) |
May
(87) |
Jun
(64) |
Jul
(93) |
Aug
(23) |
Sep
(15) |
Oct
(16) |
Nov
(62) |
Dec
(73) |
| 2014 |
Jan
(5) |
Feb
(23) |
Mar
(21) |
Apr
(11) |
May
(1) |
Jun
(19) |
Jul
(27) |
Aug
(16) |
Sep
(5) |
Oct
(37) |
Nov
(12) |
Dec
(9) |
| 2015 |
Jan
(7) |
Feb
(7) |
Mar
(44) |
Apr
(28) |
May
(5) |
Jun
(12) |
Jul
(8) |
Aug
|
Sep
(39) |
Oct
(34) |
Nov
(30) |
Dec
(34) |
| 2016 |
Jan
(66) |
Feb
(23) |
Mar
(33) |
Apr
(15) |
May
(11) |
Jun
(15) |
Jul
(26) |
Aug
(4) |
Sep
(1) |
Oct
(30) |
Nov
(10) |
Dec
|
| 2017 |
Jan
(52) |
Feb
(9) |
Mar
(24) |
Apr
(16) |
May
(9) |
Jun
(12) |
Jul
(33) |
Aug
(8) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(6) |
| 2018 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
(14) |
Jun
(1) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(8) |
Nov
(2) |
Dec
(2) |
| 2019 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(9) |
Jul
(6) |
Aug
(25) |
Sep
(10) |
Oct
(10) |
Nov
(6) |
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
(7) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(9) |
Oct
(1) |
Nov
|
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
|
From: Artyom B. <art...@ya...> - 2014-03-13 15:07:41
|
First of all it does makes sense. It is default way for libpq to pass data to the PosgreSQL engine. The binary interface is very problematic for many reasons. (like a requirement to specify the type exactly as the column type for inserts and so on) Results are passed as text as well. The casting is done on prepared statement level, i.e. when you create a prepared statement it just considers the data of specific type (especially when you use ?::type format - it is got rewritten to $1::type which is the way of postgresql to handle the type ambiguities) One thing I need to make sure that the floating point type would actually receive the decimal point for integer values. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 3/13/14, CN <cn...@fa...> wrote: Subject: Re: [Cppcms-users] Cppdb: Bound double constant becomes string of integer To: cpp...@li... Date: Thursday, March 13, 2014, 4:41 PM I have just created a ticket. Thank you for your attention! It looks to me that all bound constants are sent to database engines as string even when these constants are numbers - integer, float, double, etc. PostgreSQL can properly determine data types and cast strings to numbers when it needs to. However, I wonder data type casting causes performance penalty. Does it make sense, and is it possible, for cppdb to intelligently determine and bind numbers and send them as numeric parameters rather than strings? Regards, CN On Thu, Mar 13, 2014, at 03:40 PM, Artyom Beilis wrote: > 1st I'll look into formatting code - try to make sure that there is > always a decimal point or "E". Can you please open a ticket please? -- http://www.fastmail.fm - The professional email service ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: CN <cn...@fa...> - 2014-03-13 14:42:04
|
I have just created a ticket. Thank you for your attention! It looks to me that all bound constants are sent to database engines as string even when these constants are numbers - integer, float, double, etc. PostgreSQL can properly determine data types and cast strings to numbers when it needs to. However, I wonder data type casting causes performance penalty. Does it make sense, and is it possible, for cppdb to intelligently determine and bind numbers and send them as numeric parameters rather than strings? Regards, CN On Thu, Mar 13, 2014, at 03:40 PM, Artyom Beilis wrote: > 1st I'll look into formatting code - try to make sure that there is > always a decimal point or "E". Can you please open a ticket please? -- http://www.fastmail.fm - The professional email service |
|
From: Artyom B. <art...@ya...> - 2014-03-13 07:40:11
|
Ok.... I see, interesting problem... 1st I'll look into formatting code - try to make sure that there is always a decimal point or "E". Can you please open a ticket please? 2nd I think you can use stuff like "SELECT amount/?::REAL ..." or "SELECT amount CAST( ? as DOUBLE PRECISION) ... " to eliminate such a problem for now. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 3/13/14, CN <cn...@fa...> wrote: Subject: [Cppcms-users] Cppdb: Bound double constant becomes string of integer To: cpp...@li... Date: Thursday, March 13, 2014, 8:55 AM The following double constant 1000000. passed to PostgreSQL: const double E6=1000000.f; cppdb::result r=db_session << "SELECT amount/? FROM mytable" << E6; reaches PostgreSQL as string "1000000": Parameter:$1 = '1000000' As a result, when amount is small, the selected result always becomes 0 rather than decimal like 0.01. Is there any way I can force the parameter to be sent to back end as float or long double? Regards, CN -- http://www.fastmail.fm - One of many happy users: http://www.fastmail.fm/help/overview_quotes.html ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: CN <cn...@fa...> - 2014-03-13 06:55:09
|
The following double constant 1000000. passed to PostgreSQL: const double E6=1000000.f; cppdb::result r=db_session << "SELECT amount/? FROM mytable" << E6; reaches PostgreSQL as string "1000000": Parameter:$1 = '1000000' As a result, when amount is small, the selected result always becomes 0 rather than decimal like 0.01. Is there any way I can force the parameter to be sent to back end as float or long double? Regards, CN -- http://www.fastmail.fm - One of many happy users: http://www.fastmail.fm/help/overview_quotes.html |
|
From: Shiv S. D. <shi...@gm...> - 2014-03-10 14:24:11
|
Hi, I remember complaining about build problems when 1.0.4 was released with gcc 4.9. Today again I tried to compile and have strange output. make -j8 fails with compilation errors but simple make compiles CppCMS. I have not further investigated it. -- Respect, Shiv Shankar Dayal |
|
From: Joerg S. <jo...@br...> - 2014-03-06 23:43:54
|
On Thu, Mar 06, 2014 at 08:00:27AM -0800, Artyom Beilis wrote: > you can always create a base class for all your applications derived > from cppcms::application that would implement this functionality. None of mount, attach, add is virtual, so the natural ways to implement it don't work. Joerg |
|
From: Artyom B. <art...@ya...> - 2014-03-06 16:00:35
|
you can always create a base class for all your applications derived from cppcms::application that would implement this functionality. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 3/6/14, Joerg Sonnenberger <jo...@br...> wrote: Subject: Re: [Cppcms-users] Post-attach/add hook in cppcms::application To: cpp...@li... Date: Thursday, March 6, 2014, 3:53 PM On Thu, Mar 06, 2014 at 02:35:59AM -0800, Artyom Beilis wrote: > The factory is provided for the topmost application in hierarchy. > > How it works. > > You define an application A at mount point /foo/bar > The A has subapplications b & c, while c has sub applications d and e > > Tree: > > A > /\ > b c > /\ > d e > > Now when the factory object is requested, the ENTIRE should usually be created and stored in the pool. i.e. pool may own several A's which are actually roots of multiple trees. > > You can build a tree in a constructor or in a method that is called by the factory. > > The idea is that once the application (tree) is created the URL dispatcher would know how to route the relevant requests. > Of course when you "add" or "attach" a child to a tree you can call any his members you want before or after add/attach I understand and this is what I am doing. My question is whether the boilerplate code can be reduced by making the application class itself provide such a callback. Before: auto app = new child_app(); attach(app, ...); app->initialize(); With a cppcms::application providing such a hook directly: attach(new child_app(), ...); and attach calls the initialize() at the end. It's boring, repeative code. Joerg ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: Joerg S. <jo...@br...> - 2014-03-06 13:54:06
|
On Thu, Mar 06, 2014 at 02:35:59AM -0800, Artyom Beilis wrote: > The factory is provided for the topmost application in hierarchy. > > How it works. > > You define an application A at mount point /foo/bar > The A has subapplications b & c, while c has sub applications d and e > > Tree: > > A > /\ > b c > /\ > d e > > Now when the factory object is requested, the ENTIRE should usually be created and stored in the pool. i.e. pool may own several A's which are actually roots of multiple trees. > > You can build a tree in a constructor or in a method that is called by the factory. > > The idea is that once the application (tree) is created the URL dispatcher would know how to route the relevant requests. > Of course when you "add" or "attach" a child to a tree you can call any his members you want before or after add/attach I understand and this is what I am doing. My question is whether the boilerplate code can be reduced by making the application class itself provide such a callback. Before: auto app = new child_app(); attach(app, ...); app->initialize(); With a cppcms::application providing such a hook directly: attach(new child_app(), ...); and attach calls the initialize() at the end. It's boring, repeative code. Joerg |
|
From: Artyom B. <art...@ya...> - 2014-03-06 10:36:07
|
The factory is provided for the topmost application in hierarchy.
How it works.
You define an application A at mount point /foo/bar
The A has subapplications b & c, while c has sub applications d and e
Tree:
A
/\
b c
/\
d e
Now when the factory object is requested, the ENTIRE should usually be created and stored in the pool. i.e. pool may own several A's which are actually roots of multiple trees.
You can build a tree in a constructor or in a method that is called by the factory.
The idea is that once the application (tree) is created the URL dispatcher would know how to route the relevant requests.
Of course when you "add" or "attach" a child to a tree you can call any his members you want before or after add/attach
I hope it is clear now.
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
--------------------------------------------
On Thu, 3/6/14, Joerg Sonnenberger <jo...@br...> wrote:
Subject: Re: [Cppcms-users] Post-attach/add hook in cppcms::application
To: cpp...@li...
Date: Thursday, March 6, 2014, 1:11 AM
On Tue, Mar 04, 2014 at 11:07:12PM
-0800, Artyom Beilis wrote:
> See, mount does not actually create any instance. When
you mount an
> application you provide a factory object.
But I am looking at cppcms::application::add and
cppcms::application::attach. Both take application
instances, not
factory classes.
Joerg
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make
the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that
actually works.
Faster operations. Version large binaries. Built-in
WAN optimization and the
freedom to use Git, Perforce or both. Make the move to
Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Cppcms-users mailing list
Cpp...@li...
https://lists.sourceforge.net/lists/listinfo/cppcms-users
|
|
From: Joerg S. <jo...@br...> - 2014-03-05 23:11:19
|
On Tue, Mar 04, 2014 at 11:07:12PM -0800, Artyom Beilis wrote: > See, mount does not actually create any instance. When you mount an > application you provide a factory object. But I am looking at cppcms::application::add and cppcms::application::attach. Both take application instances, not factory classes. Joerg |
|
From: Artyom B. <art...@ya...> - 2014-03-05 07:19:22
|
No there is no such method. It works this way. When the request comes to the cppcms service event loop it does all its handling (i.e. preparing get/post data, parsing). When it is ready, it requests a relevant application from the pool and sends it to the thread pool for handling. So if there are many connections than many applications would be created and of course if there is a peak many more would be created and than released after a peak passes Now about DB connection... What SQL connector are you using? If you are using cppdb I'd recommend to use its internal connection pooling instead of keeping the connection withing the application itself. Now each time you need an sql connection you just create a cppdb::session with connection string and the connection would be fetched from a pool. What is more important it would close a connections that are out of use for a long time. One of the problems of keeping an open SQL connection withing a application is that an application can be idle for a long time. One of such cases is for example not using a connection at all because data is fetched from a cache (some real problem I used to had when I used connection-per-application approach) Another problem that in case of errors you need to be able to close connection and not use it any more (i.e. reopen). CppDB does this for you. Connection that received errors on it wouldn't go back to pool. I hope this helps. Also having better application pool implementation with more fine grained tuning is something that would be nice to have + some generic "object" pooling for any type of objects would be good thing as well. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 2/13/14, Jean-Frédéric Gaudreault <jfg...@gm...> wrote: Subject: [Cppcms-users] How can I limit the total maximum number of synchronous application object in the pool at any given time... To: cpp...@li... Date: Thursday, February 13, 2014, 6:27 PM Thanks a lot for creating CppCms, it is a wonderful framework. I made a simple project, with a synchronous application pool (like hello_world), and I was hoping I could create a DB connection inside each application object and keep it cached for reusing. Now, I am using the configuration service.applications_pool_size to set my pool size, but it seems this configuration is only for the number the maximum number of app object to cache, it does not limit the maximum number of objects created at any time. For instance, I have set the service.applications_pool_size to 24, and if I run a load test and increase the number of concurrent requests, I am able to go over 24 app objects. In fact I don't really see a limit easily, it would go over 200 app objects living at any time (in my case this translates to 200 DB connections), as long as I am hitting the service with over 200 concurrent requests. Even if I play with the worker_thread config it does not seem to limit in any way the max number of app objects. Once I stop my load test, I will see the number of app objects/db connections go back to the service.applications_pool_size I have configured. Is there any way to really limit the app pool size so that it will only go up to a maximum setting configured? Under heavy load, once this limit is reached, it should queue the requests and dispatch them at the next available application object. Also, I am using nginx with my cppcms app configured as fastcgi. I tried to see if I could limit the concurrent requests in nginx to queue them but could not find how or if this is possible. Overall, I find that being able to control the maximum number of app objects is important, in order to properly manage the memory and CPU resources used under heavy load. Also, please let me know if I'm missing something, I am just starting with cppcms but I find great potential. Thanks, Jeff -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk -----Inline Attachment Follows----- _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: Artyom B. <art...@ya...> - 2014-03-05 07:07:20
|
See, mount does not actually create any instance. When you mount an application you provide a factory object. http://cppcms.com/cppcms_ref/latest/structcppcms_1_1applications__pool_1_1factory.html There are ready factories based on templates, but nothing prevents from you to implementing your own factories and doing what ever you like, including running some post construction configurations etc. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 2/27/14, Joerg Sonnenberger <jo...@br...> wrote: Subject: [Cppcms-users] Post-attach/add hook in cppcms::application To: cpp...@li... Date: Thursday, February 27, 2014, 3:15 AM Hi all, I find myself with the need of running some actions outside the constructor of a sub-application, because virtual methods are involved or because it needs some data from the root of the hierachy. Would it make sense to provide a callback after mount succeeded? Joerg ------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: Artyom B. <art...@ya...> - 2014-03-05 07:03:41
|
You can use embedded HTTP server and run the main cppcms::service in its own thread thus combining the CppCMS WEB and the application into a single instance. Configuration - you can provide a path to Json configuration file or use json object to configure it (cppcms::service has a constructor the receives a cppcms::json::value object) Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Tue, 3/4/14, Daniel Pomrehn <dan...@gm...> wrote: Subject: [Cppcms-users] Fwd: WebGUI with RPC Json Server To: cpp...@li... Date: Tuesday, March 4, 2014, 9:04 PM Hi, I use cppcms to build a WebGUI for a C++ Application. On the GUI I want to use some AJAX calls to the C++ Application. Will I have to build a second application for handle the Ajax Request or can I put it into the same application? How must Confguration look like? I'm using URL mapping / dispatcher for different path to the pages of the WebGUI. Thanks in advanceBest regardsDanny -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk -----Inline Attachment Follows----- _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: Daniel P. <dan...@gm...> - 2014-03-04 19:04:17
|
Hi, I use cppcms to build a WebGUI for a C++ Application. On the GUI I want to use some AJAX calls to the C++ Application. Will I have to build a second application for handle the Ajax Request or can I put it into the same application? How must Confguration look like? I'm using URL mapping / dispatcher for different path to the pages of the WebGUI. Thanks in advance Best regards Danny |
|
From: Joerg S. <jo...@br...> - 2014-02-27 01:15:36
|
Hi all, I find myself with the need of running some actions outside the constructor of a sub-application, because virtual methods are involved or because it needs some data from the root of the hierachy. Would it make sense to provide a callback after mount succeeded? Joerg |
|
From: eric m. <mid...@gm...> - 2014-02-24 21:25:03
|
Hi Lucile, thanks for your comment. I figured it out already myself yesterday and do have a working example now. I might upload if later this week for others to benefit from. Thanks again! On Mon, Feb 24, 2014 at 9:37 PM, Lucile Quirion < luc...@sa...> wrote: > > Le 2014-02-22 11:47, eric middelkoop a écrit : > > Can you explain why the SyncApp supersedes and how I can make the > > AsyncApp react on the streamrequest? It must be possible to implement > > the ticker example using a dynamically created page right because > > that's what I'm after. > > > > Anyone who has a clue, please react. > > > When you look at applications_pool::get(..) in applications_pool.cpp : > you can see that a first iteration is performed on synchronious > applications to find the application witch mount_point match > HOST/SCRIPT_NAME/PATH_INFO then a second iteration is performed on > asynchronious applications. The first application found is returned. > > As you use the default mount_point SCRIPT_NAME is not checked and > SyncApp is returned instead of AsyncApp. > > You should use a mount point that checks SCRIPT_NAME, and passes > PATH_INFO for dispatching, see [0] for more information. > > Greetings, > Lucile > > [0] http://cppcms.com/cppcms_ref/latest/classcppcms_1_1mount__point.html > > > ------------------------------------------------------------------------------ > Flow-based real-time traffic analytics software. Cisco certified tool. > Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer > Customize your own dashboards, set traffic alerts and generate reports. > Network behavioral analysis & security monitoring. All-in-one tool. > > http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > -- Groetjes, Eric http://www.lightandmagicphotography.nl http://www.lightandmagicphotography.com On Mon, Feb 24, 2014 at 9:37 PM, Lucile Quirion < luc...@sa...> wrote: > > Le 2014-02-22 11:47, eric middelkoop a écrit : > > Can you explain why the SyncApp supersedes and how I can make the > > AsyncApp react on the streamrequest? It must be possible to implement > > the ticker example using a dynamically created page right because > > that's what I'm after. > > > > Anyone who has a clue, please react. > > > When you look at applications_pool::get(..) in applications_pool.cpp : > you can see that a first iteration is performed on synchronious > applications to find the application witch mount_point match > HOST/SCRIPT_NAME/PATH_INFO then a second iteration is performed on > asynchronious applications. The first application found is returned. > > As you use the default mount_point SCRIPT_NAME is not checked and > SyncApp is returned instead of AsyncApp. > > You should use a mount point that checks SCRIPT_NAME, and passes > PATH_INFO for dispatching, see [0] for more information. > > Greetings, > Lucile > > [0] http://cppcms.com/cppcms_ref/latest/classcppcms_1_1mount__point.html > > > ------------------------------------------------------------------------------ > Flow-based real-time traffic analytics software. Cisco certified tool. > Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer > Customize your own dashboards, set traffic alerts and generate reports. > Network behavioral analysis & security monitoring. All-in-one tool. > > http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > -- Groetjes, Eric http://www.lightandmagicphotography.nl http://www.lightandmagicphotography.com |
|
From: Lucile Q. <luc...@sa...> - 2014-02-24 20:57:20
|
Le 2014-02-22 11:47, eric middelkoop a écrit : > Can you explain why the SyncApp supersedes and how I can make the > AsyncApp react on the streamrequest? It must be possible to implement > the ticker example using a dynamically created page right because > that's what I'm after. > > Anyone who has a clue, please react. > When you look at applications_pool::get(..) in applications_pool.cpp : you can see that a first iteration is performed on synchronious applications to find the application witch mount_point match HOST/SCRIPT_NAME/PATH_INFO then a second iteration is performed on asynchronious applications. The first application found is returned. As you use the default mount_point SCRIPT_NAME is not checked and SyncApp is returned instead of AsyncApp. You should use a mount point that checks SCRIPT_NAME, and passes PATH_INFO for dispatching, see [0] for more information. Greetings, Lucile [0] http://cppcms.com/cppcms_ref/latest/classcppcms_1_1mount__point.html |
|
From: Marcel H. <ke...@co...> - 2014-02-23 19:41:49
|
> cppcms::service service(argc, argv); > booster::intrusive_ptr<AsyncApp> asyncServer = new > AsyncApp(service); > service.applications_pool().mount(asyncServer); > > service.applications_pool().mount(cppcms::applications_factory<SyncApp>()); > service.run(); > I think what's missing here is a mount_point [0]. When you provide one, you should be able to access both. It would be nice if somebody else would also mention something ;) Greetings, Marcel [0] http://cppcms.com/cppcms_ref/latest/classcppcms_1_1applications__pool.html |
|
From: eric m. <mid...@gm...> - 2014-02-22 16:48:03
|
Hi Marcel,
I did read your emails thoroughly, although missed the link to the
applications_pool pages, as I thought you meant some piece of code by [0]
at first. I do understand that static ticker example. That is not the
problem, anymore.
What I indeed want is what you mentioned in your last response: I want the
streamed data to be displayed on a webpage that is not produced statically
(from the filesytem) but dynamically. I assumed that that could be done
from the same application but apparently that is not the case. You mention
multiple applications. Could it be as simple as registering both an
asynchronous application and a synchronous application in main() like this
or is that not possible at all?
cppcms::service service(argc, argv);
booster::intrusive_ptr<AsyncApp> asyncServer = new
AsyncApp(service);
service.applications_pool().mount(asyncServer);
service.applications_pool().mount(cppcms::applications_factory<SyncApp>());
service.run();
In the AsyncApp class I have implemented the ticker example and in the
SynApp class a variant of the tut_url_mapping example.
The constructor of AsynApp has mapper().root("/ticker"); and that of
SyncApp has mapper().root("/robot");
The config file is as follows:
{
"service" : {
"api" : "http",
"port" : 8080
},
"http" : {
"script_names" : [ "/robot", "/ticker" ]
},
"file_server" : {
"enable" : true,
"document_root" : "."
},
}
I added a method virtual string report() to cppcms::application that is
called every time application::main() is called and reports which
application calls it.
If I only mount the SyncApp and access the page by
127.0.0.1:8080/robot/showstatus than showstatus.html is displayed and the
following output follows on the console:
Sync::Sync() called
SyncApp->CppCMS::application::main(/showstatus) called
SyncApp::showStatus() called
SyncApp->CppCMS::application::main() called
If I only mount the AsyncApp and access the stream via
127.0.0.1:8080/showstatus.html (with var stream = new
EventSource('/ticker');) then the showstatus.html is displayed and the
stream of tickers updates the page as expected. The following output
follows on the console:
Async::Async() called
AsyncApp::main called
If I mount both SyncApp and AsyncApp and access
127.0.0.1:8080/showstatus.html than the page is displayed but no streaming
data. The following output follows on the console:
Async::Async() called
Sync::Sync() called
SyncApp->CppCMS::application::main() called
SyncApp->CppCMS::application::main() called
Which means to me that SyncApp gets to handle the request and not AsyncApp.
If I mount both and access 127.0.0.1:8080/robot/showstatus that the page is
displayed but no streaming data. The output on the console is slightly
different but the result is the same:
Async::Async() called
Sync::Sync() called
SyncApp->CppCMS::application::main(/showstatus) called
SyncApp::showStatus() called
SyncApp->CppCMS::application::main() called
Here also SyncApp::main is called and not AsyncApp::main.
Can you explain why the SyncApp supersedes and how I can make the AsyncApp
react on the streamrequest? It must be possible to implement the ticker
example using a dynamically created page right because that's what I'm
after.
Anyone who has a clue, please react.
Kind regards,
Eric
If I don't mount the SyncApp it works exactly as the ticker example,
updating the static page with the streamed data. If I don't mount the
AsyncApp it works exactly as the tut_url_mapping example. I if mount both
and send the same page to the browser but now dynamically from SyncApp,
there is no streaming data, which I would have expected as the page is
exactly the same page and there is an asynchronous app registered that
proved to respond when the page was loaded statically. Any ideas?
The server will be approached by only a single user so multiuser aspects
are no issue here.
Greetz,
Eric
On Sat, Feb 22, 2014 at 2:11 PM, Marcel Hellwig <ke...@co...> wrote:
> Hi Eric,
>
> I have the feeling that you don't read my mails... I apologize, that I'm
> not a native speaker but I think, that you can understand what I write.
>
> I'd like to mention it once again.
>
> ***A stream is not something that you view in your browser!***
>
> It's not a webpage, it's a stream of information that can be access and
> evaluated by a javascript/cpp/perl/python/... programm.
> There are two major problems in your approach.
>
> 1. You view the stream in your browser. That's not how it works. Please
> adapt your 'showstatus.html' in line 14 to this:
>
> > var stream = new EventSource('/robot/showstatus');
>
> and replace the showStatus method with this
>
> > void MyApp::showStatus()
> > {
> > stream_->accept(release_context());
> > }
>
> Then you can access it via:
>
> > http://localhost:8080/showstatus.html
>
> and see the promised result. I also attached the 'corrected' version.
>
> I think, that your problem is, that you want both - stream and page - in
> on method, but that won't work. You must have a synchronous app that
> will deliver the page content [0] and a asynchronous app that will
> deliver the data via sse.
> The static content will be delivered via the internal file server of
> cppcms in this way, but you should not rely on that in a productive
> environment [1].
> So. You need one application for the sse part and another application
> for the webpage part.
>
>
> The second major problem in your current version is, that you cannot
> open that (wrong) page twice. Try to open another tab and view that page
> again. It won't work. The can and should read the reason why [2][3].
>
> So I hope that you won't be angry. Read the given pages and then I hope
> you can answer your questions that you have. Of course, feel free to ask
> more questions.
>
> Greetings,
> Marcel
>
>
> [0] http://cppcms.com/wikipp/en/page/cppcms_1x_tut_hello
> [1] http://cppcms.com/wikipp/en/page/cppcms_1x_serving_static_files
> [2] http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime
> [3] http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop
>
--
Groetjes,
Eric
http://www.lightandmagicphotography.nl
http://www.lightandmagicphotography.com
|
|
From: Marcel H. <ke...@co...> - 2014-02-22 13:11:40
|
Hi Eric,
I have the feeling that you don't read my mails... I apologize, that I'm
not a native speaker but I think, that you can understand what I write.
I'd like to mention it once again.
***A stream is not something that you view in your browser!***
It's not a webpage, it's a stream of information that can be access and
evaluated by a javascript/cpp/perl/python/... programm.
There are two major problems in your approach.
1. You view the stream in your browser. That's not how it works. Please
adapt your 'showstatus.html' in line 14 to this:
> var stream = new EventSource('/robot/showstatus');
and replace the showStatus method with this
> void MyApp::showStatus()
> {
> stream_->accept(release_context());
> }
Then you can access it via:
> http://localhost:8080/showstatus.html
and see the promised result. I also attached the 'corrected' version.
I think, that your problem is, that you want both - stream and page - in
on method, but that won't work. You must have a synchronous app that
will deliver the page content [0] and a asynchronous app that will
deliver the data via sse.
The static content will be delivered via the internal file server of
cppcms in this way, but you should not rely on that in a productive
environment [1].
So. You need one application for the sse part and another application
for the webpage part.
The second major problem in your current version is, that you cannot
open that (wrong) page twice. Try to open another tab and view that page
again. It won't work. The can and should read the reason why [2][3].
So I hope that you won't be angry. Read the given pages and then I hope
you can answer your questions that you have. Of course, feel free to ask
more questions.
Greetings,
Marcel
[0] http://cppcms.com/wikipp/en/page/cppcms_1x_tut_hello
[1] http://cppcms.com/wikipp/en/page/cppcms_1x_serving_static_files
[2] http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime
[3] http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop
|
|
From: Marcel H. <ke...@co...> - 2014-02-22 12:02:34
|
On 22.02.2014 11:20, eric middelkoop wrote:
> Hello,
Hi Eric,
> While having all the rest the same as in the ticker example.
>
> I open the page with 127.0.0.1:8080/robot/camerasettings
> <http://127.0.0.1:8080/robot/camerasettings> and the page is displayed
> correctly but the stream keeps loading and is not being displayed. After
> stopping the server, the data is displayed and looks like this:
>
I think you still haven't fully understood the concept of streams. A
stream is a non-ending flow of information.
Therefore your browser cannot display the infos except the stream has
been closed (you stopped the server), because it doesn't know if there
is anything left to display (and it is indeed).
So what you are missing is a html page like the_ticker.html with
javascript inside, that opens the stream and gets the needed
information. I think you should look at 'the_ticker.html' a second time,
especially the javascript part.
>
> void MyApp::cameraSettings()
> {
> string page = FileSystem().readFileIntoString("the_ticker.html");
> stream_->accept(release_context());
> response().out() << page.c_str();
> }
I don't know what you are trying, but it's getting wrong ;)
> So I have two questions:
>
> 1) How do I combine server side events with url dispatching in cppcms? As I would like to create and send the page to the browser from a method and start to stream events after the page has loaded.
Hmmm, you should (if it's possible) let the stream run from the
beginning of your application. That's how it should work. The
dispatching is the same as in every other application. You have a method
that creates a page with response().out() << "foo" or with a template.
It's up to you.
>
> 2) How do I stop the stream if the user switches to another page or does it stop itself?
As I said, you should not.
>
> I can provide full sourcecode if necessary. Sofar I couldn't find other comparable examples.
>
> My guess is that it shouldn't be all that difficult once you know, but currently I do not (-;
>
If you really need to start and stop the stream, I *think* it should
work via [0]. You mount a asynchronous application and as soon the
pointer becomes 'illegal' the application will be dismounted. Maybe you
should look at that, but I think Artyom can help here more than I can.
Maybe he'll clarify this.
Greetings
[0]
http://cppcms.com/cppcms_ref/latest/classcppcms_1_1applications__pool.html#a5df195e454c857c4c064f8593c76fc45
|
|
From: eric m. <mid...@gm...> - 2014-02-22 10:20:26
|
Hello, I'm trying to combine the features of the ticker example ( https://svn.code.sf.net/p/cppcms /code/framework/trunk/contrib/server_side/sse/), i.e. streaming data from the server to update a webpage with url dispatching instead of using the default main function and a static html page. So instead of the following code in ticker.cpp: void main(std::string /*url*/) { stream_->accept(release_context()); } I would like to use something like: MyApp::MyApp(cppcms::service &service) : cppcms::application(service), tm_(service.get_io_service()), price_(1.0) { dispatcher().assign("/camerasettings",&MyApp::cameraSettings,this); mapper().assign("Camera Settings","/camerasettings"); mapper().root("/robot"); stream_ = sse::state_stream::create(service.get_io_service()); wait(); } void MyApp::cameraSettings() { string page = FileSystem().readFileIntoString("the_ticker.html"); response().out() << page.c_str(); stream_->accept(release_context()); } While having all the rest the same as in the ticker example. I open the page with 127.0.0.1:8080/robot/camerasettings and the page is displayed correctly but the stream keeps loading and is not being displayed. After stopping the server, the data is displayed and looks like this: Stock Price Price: id:8 data:2.54208 id:9 data:2.97668 id:10 data:3.19061 id:11 data:2.67639 id:12 data:3.28474 id:13 data:3.08663 id:14 data:2.30425 id:15 data:1.74076 id:16 data:2.41898 id:17 data:2.01105 id:18 data:2.05962 id:19 data:3.00517 id:20 data:3.54789 id:21 data:4.08772 id:22 data:4.87077 id:23 data:4.57569 id:24 data:5.41374 id:25 data:6.3124 If on the other hand the stream is accepted before the response is sent, like this void MyApp::cameraSettings() { string page = FileSystem().readFileIntoString("the_ticker.html"); stream_->accept(release_context()); response().out() << page.c_str(); } an exception is thrown: cppcms, error: Caught exception [Access to unassigned context] which seems to be kind of logical, the page does not show, but after stopping the server, the browser displays the streamed data as follows: id:15 data:1.74076 id:16 data:2.41898 id:17 data:2.01105 id:18 data:2.05962 id:19 data:3.00517 id:20 data:3.54789 So I have two questions: 1) How do I combine server side events with url dispatching in cppcms? As I would like to create and send the page to the browser from a method and start to stream events after the page has loaded. 2) How do I stop the stream if the user switches to another page or does it stop itself? I can provide full sourcecode if necessary. Sofar I couldn't find other comparable examples. My guess is that it shouldn't be all that difficult once you know, but currently I do not (-; Any help is welcome here. Best regards, Eric |
|
From: eric m. <mid...@gm...> - 2014-02-21 17:51:17
|
Sorry... Have found it. It does actually work. I was wondering why chat was updating and ticker didn't. While adapting the code of ticker towards chat to see where the problem is, I reread your emails and found the cause of the problem. I was using http://localhost:8080/ticker instead of http://localhost:8080/the_ticker.html Thanks for your support. On Fri, Feb 21, 2014 at 6:35 PM, eric middelkoop <mid...@gm...>wrote: > I tried Chrome instead of Firefox and that reacts differently. Its reading > the stream but doesn't show anything until I stop the server. Then it > displays the same as when connected via the terminal. So it does work in > the end (no idea why Firefox behaves differently). Any idea how to make the > browser refresh the page after every change from the server? > > > On Fri, Feb 21, 2014 at 6:25 PM, eric middelkoop < > mid...@gm...> wrote: > >> Hi, >> >> Yes when I start the ticker and run wget localhost:8080/ticker -qO - | >> cat from another terminal I get a steady stream of tickers updates. >> id:44 >> data:7.36238 >> >> id:45 >> data:7.73572 >> >> id:46 >> data:7.913 >> >> id:47 >> data:8.63035 >> >> id:48 >> data:9.47829 >> >> id:49 >> data:10.1078 >> >> id:50 >> data:10.9298 >> >> >> When instead I start Firefox and go to localhost it asks me to save the >> data as a file. I downloaded the latest version of cppcms only last week. >> >> Does it work with you? And if yes what browser and os are you using? >> >> I just don't get it... >> >> Best regards, >> Eric >> >> >> >> On Fri, Feb 21, 2014 at 9:46 AM, Marcel Hellwig <ke...@co...>wrote: >> >>> >>> >>> On 21.02.2014 07:58, eric middelkoop wrote: >>> > Hi Marcel, >>> > >>> > Yes I checked. Javascript is enabled in Firefox. Do you have any idea >>> > what is going wrong here? >>> >>> Are you sure your application is running und reachable? >>> Did you try the command I sent you? >>> >>> > wget localhost:8080/ticker -qO - | cat >>> >>> If that works the page should also work: >>> >>> http://localhost:8080/the_ticker.html >>> >>> if not. Try to update your cppcms version and after that I don't have >>> any clue :D >>> >>> Greetings >>> >>> >> >> >> -- >> Groetjes, >> Eric >> >> http://www.lightandmagicphotography.nl >> http://www.lightandmagicphotography.com >> > > > > -- > Groetjes, > Eric > > http://www.lightandmagicphotography.nl > http://www.lightandmagicphotography.com > -- Groetjes, Eric http://www.lightandmagicphotography.nl http://www.lightandmagicphotography.com |
|
From: eric m. <mid...@gm...> - 2014-02-21 17:35:32
|
I tried Chrome instead of Firefox and that reacts differently. Its reading the stream but doesn't show anything until I stop the server. Then it displays the same as when connected via the terminal. So it does work in the end (no idea why Firefox behaves differently). Any idea how to make the browser refresh the page after every change from the server? On Fri, Feb 21, 2014 at 6:25 PM, eric middelkoop <mid...@gm...>wrote: > Hi, > > Yes when I start the ticker and run wget localhost:8080/ticker -qO - | cat > from another terminal I get a steady stream of tickers updates. > id:44 > data:7.36238 > > id:45 > data:7.73572 > > id:46 > data:7.913 > > id:47 > data:8.63035 > > id:48 > data:9.47829 > > id:49 > data:10.1078 > > id:50 > data:10.9298 > > > When instead I start Firefox and go to localhost it asks me to save the > data as a file. I downloaded the latest version of cppcms only last week. > > Does it work with you? And if yes what browser and os are you using? > > I just don't get it... > > Best regards, > Eric > > > > On Fri, Feb 21, 2014 at 9:46 AM, Marcel Hellwig <ke...@co...>wrote: > >> >> >> On 21.02.2014 07:58, eric middelkoop wrote: >> > Hi Marcel, >> > >> > Yes I checked. Javascript is enabled in Firefox. Do you have any idea >> > what is going wrong here? >> >> Are you sure your application is running und reachable? >> Did you try the command I sent you? >> >> > wget localhost:8080/ticker -qO - | cat >> >> If that works the page should also work: >> >> http://localhost:8080/the_ticker.html >> >> if not. Try to update your cppcms version and after that I don't have >> any clue :D >> >> Greetings >> >> > > > -- > Groetjes, > Eric > > http://www.lightandmagicphotography.nl > http://www.lightandmagicphotography.com > -- Groetjes, Eric http://www.lightandmagicphotography.nl http://www.lightandmagicphotography.com |
|
From: eric m. <mid...@gm...> - 2014-02-21 17:25:27
|
Hi, Yes when I start the ticker and run wget localhost:8080/ticker -qO - | cat from another terminal I get a steady stream of tickers updates. id:44 data:7.36238 id:45 data:7.73572 id:46 data:7.913 id:47 data:8.63035 id:48 data:9.47829 id:49 data:10.1078 id:50 data:10.9298 When instead I start Firefox and go to localhost it asks me to save the data as a file. I downloaded the latest version of cppcms only last week. Does it work with you? And if yes what browser and os are you using? I just don't get it... Best regards, Eric On Fri, Feb 21, 2014 at 9:46 AM, Marcel Hellwig <ke...@co...> wrote: > > > On 21.02.2014 07:58, eric middelkoop wrote: > > Hi Marcel, > > > > Yes I checked. Javascript is enabled in Firefox. Do you have any idea > > what is going wrong here? > > Are you sure your application is running und reachable? > Did you try the command I sent you? > > > wget localhost:8080/ticker -qO - | cat > > If that works the page should also work: > > http://localhost:8080/the_ticker.html > > if not. Try to update your cppcms version and after that I don't have > any clue :D > > Greetings > > -- Groetjes, Eric http://www.lightandmagicphotography.nl http://www.lightandmagicphotography.com |