World: r3wp
[!Cheyenne] Discussions about the Cheyenne Web Server
older newer | first last |
Terry 8-Nov-2009 [6407] | ie: user clicks a button on a page, send http to Cheyenne.. Cheyenne pushes a message via the socket, receives a response, and pushes the result back to the page. |
Dockimbel 9-Nov-2009 [6408] | I would build a new "protocol" module for the underlying UniServe to achieve that. |
Terry 9-Nov-2009 [6409x2] | I've had an idea for Cheyenne.. using it to interface with Freeswitch.. there's a vacuum at the moment, and would be a great opportunity |
http://www.freeswitch.org/ | |
Pekr 9-Nov-2009 [6411x3] | bzzz ... loading :-) |
Is freeswithc something like Asterisk? | |
ah, wrong channel, sorry ... | |
Terry 9-Nov-2009 [6414x4] | I have my old Framewerks (Cheyenne ) connecting via tcp port.. can control all aspects of calls from there.. but my rebol port knowledge is really rusty.. don't even recognize my own code |
Yeah, Freeswitch is better than Asterisk though. | |
There's a good article on installing Freeswitch here http://www.linux-magazine.com/w3/issue/106/Freeswitch.pdf | |
FreePBX (an GUI for Asterisk) is building an interface to freeswitch, but the code is a nightmare | |
Kaj 9-Nov-2009 [6418x5] | Terry, you can do that with async HTTP in JavaScript (AJAX without the X(ML)) |
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 [6456] | 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) |
older newer | first last |