World: r3wp
[!Cheyenne] Discussions about the Cheyenne Web Server
older newer | first last |
Kaj 9-Nov-2009 [6419x4] | Look at the source of http://tryrebol.esperconsultancy.nlfor the JavaScript code |
There's nothing specific you have to do on the web server side except providing the service interfaces (regular HTTP responses) | |
My example is only fourty lines or so and implements a complete command service bus; similar to REBOL/Services but much simpler, so JavaScript can do it | |
At the Cheyenne side you can use the regular Freeswitch interfaces | |
Terry 10-Nov-2009 [6423x2] | Yeah Kaj, it's the Cheyenne side i'm referring to. |
I want to unify communications using Cheyenne (Rebol) as the middleware, pulling and pushing info through and to each other ie: an event message from Freeswitch is processed via xml socket, processed, and pushed to a web page via comet / ajax.. and back again.. | |
Kaj 10-Nov-2009 [6425x2] | I'm not sure it makes sense to let Freeswitch initiate events, because you can' t push them to the web browser, anyway. The browser will have to poll |
Maybe it would be advantageous for caching some Freeswith results, but other than that it would be simpler to have Cheyenne initiate the communications | |
Terry 10-Nov-2009 [6427] | Yeah, I'll have Cheyenne create the port to Freeswitch, and you can push data to a page via Comet. |
Kaj 10-Nov-2009 [6428] | I see. Interesting |
MikeL 10-Nov-2009 [6429] | I'm running Cheyenne as port 8080 on a machine that also runs IIS. I want to get Windows logon which IIS can force for a directory. Anyone doing this already? |
Kaj 11-Nov-2009 [6430x4] | Terry, I've been thinking about it, and it seems to me that Cheyenne is not designed to support Comet well |
Cheyenne forks Uniserve processes to handle requests. These are full REBOL instances that seem to take around 2 MB each just after initialisation | |
Comet requires a connection to stay open, so it looks like this will take a Uniserve process for each open connection. That puts a rather low limit on the simultaneous clients you can handle with the memory of one server | |
I'd say one Uniserve handler should normally be able to handle several tens of requests per second, so even when you would let each client browser do a poll request every second, compared to that you loose at least an order of magnitude in scalability with Comet | |
Dockimbel 11-Nov-2009 [6434x2] | Comet requires a connection to stay open, so it looks like this will take a Uniserve process for each open connection. A Uniserve process (worker process) is not bound to a given client connection. Each worker accepts requests from ANY client connection, so it can handle hundreds of Comet-like connections with a few worker processes as long as each request doesn't take much time. For example, if each request takes 50ms, with 10 worker processes, you can handle 200 req/sec. |
The UniServe engine multiplexes client requests between available worker processes (and fork new ones if required). | |
Pekr 11-Nov-2009 [6436] | Doc - just curious - how do you know, which worker process is free to work? :-) |
Dockimbel 11-Nov-2009 [6437x2] | Using a busy flag associated with each worker. |
The flag is set when a request is assigned to a process and reset when the worker answers back. | |
Kaj 11-Nov-2009 [6439] | Thanks, good info |
Terry 11-Nov-2009 [6440] | Hey Doc, any hints / docs on building a Uniserve service that could handle what I need? |
Dockimbel 11-Nov-2009 [6441x2] | UniServe API documentation : http://www.softinnov.org/rebol/uni-guide.html HTTP async client implementation : http://www.softinnov.org/tmp/HTTP-client.zip |
From what I've understood of your need, you should look into the "Protocol API" part (and not the "Service API" part). | |
Terry 12-Nov-2009 [6443x4] | k, thanks. |
Hmm, i think i did this some time ago.. pre Cheyenne days. | |
I remember googling a coding problem one time, and found a solution.. thought to myself.. "this guy knows the situatioh".. only to realize i was my own code i had posted some years earlier. ;() | |
So /Service acts as a receiving port vs connecting to a port via /Protocol | |
Dockimbel 12-Nov-2009 [6447] | Yes. /Protocol = client side. |
Terry 12-Nov-2009 [6448x3] | I just can't seem to speak to this remote port with Rebol or Uniserve no matter what i try |
This PHP code works fine.. <?php $password = "ClueCon"; $port = "8021"; $host = "127.0.0.1"; function event_socket_create($host, $port, $password) { $fp = fsockopen($host, $port, $errno, $errdesc) or die("Connection to $host failed"); socket_set_blocking($fp,false); if ($fp) { while (!feof($fp)) { $buffer = fgets($fp, 1024); usleep(100); //allow time for reponse if (trim($buffer) == "Content-Type: auth/request") { fputs($fp, "auth $password\n\n"); break; } } return $fp; } else { return false; } } function event_socket_request($fp, $cmd) { if ($fp) { fputs($fp, $cmd."\n\n"); usleep(100); //allow time for reponse $response = ""; $i = 0; $contentlength = 0; while (!feof($fp)) { $buffer = fgets($fp, 4096); if ($contentlength > 0) { $response .= $buffer."<br>"; } if ($contentlength == 0) { //if contentlenght is already don't process again if (strlen(trim($buffer)) > 0) { //run only if buffer has content $temparray = split(":", trim($buffer)); if ($temparray[0] == "Content-Length") { $contentlength = trim($temparray[1]); } } } usleep(100); //allow time for reponse //optional because of script timeout //don't let while loop become endless if ($i > 10000) { break; } if ($contentlength > 0) { //is contentlength set //stop reading if all content has been read. if (strlen($response) >= $contentlength) { break; } } $i++; } return $response; } else { echo "no handle"; } } $fp = event_socket_create($host, $port, $password); $cmd = "api show dialplan"; $response = event_socket_request($fp, $cmd); echo $response; fclose($fp); | |
I can open a port, and get the authentication challenge.. i iget a content-type: auth/request.. .when i insert into the port "auth Cluecon \n\n" i get no reply.. just times out with a timeout error? | |
Will 20-Nov-2009 [6451] | nice http://pushmodule.slact.net/ |
Kaj 20-Nov-2009 [6452] | Very nice indeed |
Janko 24-Nov-2009 [6453] | set-cookie docs don't exist and it says n/a .. does this mean the word is not there any more or something else? Do I have to manually set http response headers to set cookies? |
Dockimbel 24-Nov-2009 [6454x2] | Set-cookie is on the todo list but hasn't been implemented yet. So, for now, you have to set http header manually. |
IIRC, there's some code for setting cookies in the rebol.org library. | |
Janko 24-Nov-2009 [6456x3] | aha, no problem .. how can I read the cookies .. looking at request headers I guess (I forgot a little about how exactly cookies are doing) |
doing = work | |
aha I remember :) | |
Dockimbel 24-Nov-2009 [6459] | request/headers/cookie |
Janko 24-Nov-2009 [6460x3] | aha, you already parse it .. cool |
I am creating an simple affiliate system for cebelca.biz , but it will be made so you can reuse it on any page without installing aff system on server | |
so if anyone needs it, tell me | |
Terry 26-Nov-2009 [6463x2] | I'm coming to the conclusion that any communication other than via HTTP is a waste of time. Sockets suck. |
I mean, this low level coding is a pain. | |
Robert 26-Nov-2009 [6465x2] | IMO HTTP sucks. Since years people try to make stateless HTPP stateful. One just needs a simple socket and than handle everything via a multiplexed channel system through this. |
And, with some tricks everything can be tunneled through port 80 ;-) See Skype. | |
Henrik 26-Nov-2009 [6467] | Well, HTTP works ok as long as you treat it like what it is: Stateless. |
Janko 1-Dec-2009 [6468] | I am trying to use the set-locale locales-dir .. but I wasn't able to get it work |
older newer | first last |