If a browser has the node runtime, doesn’t that also contain express and socket.io libraries? And if so, then can’t you instantiate an http server within the browser context itself?
I mean - does a socket in a browser always act as a ‘client’ - and communicate with a backend server?
Thanks
AV
The Chrome browser uses the V8 engine to compile and run JavaScript. Node.js uses the same V8 engine. But that doesn't mean that the browser has node, nor does it include some of the modules like http which are necessary to run an express server.
If a browser has the node runtime
That is not what a browser has. It does NOT have the node runtime.
The Chrome browser uses the V8 engine to run Javascript. That is not a runtime library. That is just the Javascript interpreter that makes the raw language run. The browser then adds a library of stuff that is specific to the browser such as a DOM library and various interfaces that are browser specific such as XMLHttpRequest and others.
node.js also uses the same V8 engine for raw language support. But, then node.js adds its own runtime library (that's where the http library is) and those libraries are not in the browser in any way.
And if so, then can’t you instantiate an http server within the browser context itself?
No, you cannot.
I mean - does a socket in a browser always act as a ‘client’ - and communicate with a backend server?
Browsers have two main ways of communicating with an outside server. They can make an http request (often called an Ajax request in the context of the browser). Or, they can make a webSocket connection to another server and exchange messages over the webSocket. The browser would always be the client. It would initiate the connection to some server. There is no way for an outside agent to "connect to a user's browser". Instead, the browser has to connect to the outside agent.
Related
So I have this server where I host more than one website for professional purposes. But I also like to develop game websites and I would like to create a roguelike game with HTML5.
The game engine itself would be developped in C++ on the server and the client should ask the server what changes in the environment after every move.
So, normally, I would send an ajax request to the server where apache would reroute the request to my C++ application which is running as a FastCGI Service. My C++ application would check the session, look up if the movement is valid, change the internal values so that the character moves, also changes other things in the environment, and would then send the changes back to the client.
But ajax requests can be relatively slow, opening and closing connections all the time. So when I read about websockets, I thought I was in heaven until I saw that it will interfere with Apache and Apache is not really optimized to work with it.
Obviously, I could create a web socket on a different port, but with all those firewalls out there, I don't think that's a good option.
So, is there a way to combine the two? Where apache is able to understand that a websocket request should be ignored and passed on to my application instead?
Does PhantomJS work client side or server side? I know JavaScript can work client and server side, but I don't know which one PhantomJS is based on?
Is PhantomJS client side or server side?
Is it client-side?
Yes, if you mean, does PhantomJS emulate/replace the browser which we usually think of as "client-side"--that is its purpose in life!
No, if by "client-side", you mean "runs in a browser"--because PhantomJS itself is a browser (albeit with no visual display of the screen--hence the term "headless").
Is it server-side?
Yes, if by "server-side" you mean PhantomJS could run on some computer which I might think of as a server, including one off in the cloud somewhere.
No, if by "server-side" you mean PhantomJS implements, or would be used to implement, a web server handling HTTP calls and implementing some API.
Do you have some specific issue you were trying to solve, or is this just curiosity and clarification of terminology?
PhantomJS is a headless browser. The PhantomJS API is used to control the browser itself, as well as allowing you to inject Javascript within the DOM context.
PhantomJS is a HTTP client.
You can put PhantomJS on a server to act as an automated client. In that way it you could consider it server side. But it is still a HTTP client at it's core.
The purpose of PhantomJS is instead of using a mouse and keyboard to control a browser and complete some actions, for instance: open a new window, type a url, enter, find a link and click it. You can automate those actions programmatically with Javascript.
If you are considering the conventional terminology meaning; code inside a loaded webpage being Client Side and code running on a HTTP Server being Server Side.
Usually PhantomJS is Client Side that is run on Server Side.
I've been researching how to connect Tomcat and apache http server because I will have my web application written in angular deployed in apache http server 2.2 (currently succesfully tested on my own computer, local), and my REST service written in java deployed in Tomcat v6,
and what I want now is that when some component is clicked, to make a http request (like this http://localhost:8080/rest/getCars/20130505) that connects with the servlet and use the json provided to use the information provided in another component.
So I have created my own url/json to test the web application on itself, but as I said, it is possible to make the same thing but with a real http URI like it can be seen here: https://angular.io/docs/ts/latest/guide/server-communication.html#!#cors
They use:
let wikiUrl = 'http://en.wikipedia.org/w/api.php';
And I use, as of right now:
private datesUrl = 'src/example.json'; // URL to web API
#Injectable()
getDates(): Observable<Date[]> {
return this.http.get(this.datesUrl)
.map(this.extractData)
.catch(this.handleError);
}
So I believe my next step would be to change that datesUrl and write the http written above: http://localhost:8080/rest/getCars/20130505, so that it connects to Tomcat.
But my problem is that I don't know if this is going to work without any connection done between apache http server and tomcat. I've seen there are connectors, like mod_jk and mod_proxy http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
and so on. I would like to know if, in my case, if I need to use this modules for apache http server or it's not necessary, since I have never seen any of this and install the modules is proving to be a challenge. The end game objective I have is to go from local to a real server, but as far as I know there is no need for anyone from the outside to use the webpage, it's only for the business itself, so with access to the server/machine I could still access localhost, same as I do when I test it locally.
You don't need any special connection between the PHP server and the Tomcat server: it's a plain-old HTTP request. Tomcat doesn't care if your PHP script made that request, or if it came from the open internet.
In the case of the PHP script making the request, it's making its standard HTTP call, and doesn't care that you are running a Tomcat server locally or whatever. Just go ahead and do it. If Tomcat is already responding to HTTP requests on that URL, then calling it from PHP requires no further configuration.
I've followed the instructions here: http://guac-dev.org/doc/gug/installing-guacamole.html
This says
Guacamole is separated into two pieces: guacamole-server, which provides the guacd proxy and related libraries, and guacamole-client, which provides the client to be served by your servlet container, usually Tomcat.
guacamole-client is available in binary form, but guacamole-server must be built from source. Don't be discouraged: building the components of Guacamole from source is not as difficult as it sounds, and the build process is automated. You just need to be sure you have the necessary tools installed ahead of time. With the necessary dependencies in place, building Guacamole only takes a few minutes.
And then proceed to describe how to install guacamole-server and use it. I can now go to http://localhost:8080/guacamole/ and access the server and see which clients have connected.
How do I connect a client though? I see no documentation of where the remote desktop needs to browse to in order to run the guacamole-client?
Or have I totally misunderstood this?
The key phrase in the quoted documentation is:
... guacamole-client, which provides the client to be served by your servlet container, usually Tomcat.
"guacamole-client" is the web application and the client. When a user visits the URL for your Guacamole server, logs in, and clicks on a connection, they are connected to the corresponding remote desktop via Guacamole's JavaScript client which is served to their browser like any other web application.
I can now go to http://localhost:8080/guacamole/ and access the server and see which clients have connected.
The list you see when you first log in to your Guacamole server is not the list of clients that have connected; it is the list of connections to remote desktops which are available. If you click on one of those connections, you will be connected using Guacamole's own built-in JavaScript client.
How do I connect a client though? I see no documentation of where the remote desktop needs to browse to in order to run the guacamole-client?
The remote desktop does not need to do anything - Guacamole will simply connect to it. You can see a video of the overall user experience on the Guacamole website which may hopefully clear things up for you:
https://vimeo.com/116207678
Overall:
You deploy guacamole-client (the web application) and install guacamole-server (the remote desktop proxy that the web application uses in the backend). The combination of these two pieces of software makes up a typical Guacamole server.
You and your users can log in through the web application and connect to remote desktops using a web browser.
You do not need to explicitly run a client.
It looks like this
Internet -> Guacamole server (on the local network) -> Desktop pc
I installed Guacamole in a vmware enviroment on Ubuntu.
There is a file in /etc/guacamole what is called user-mapping.xml
In that file you add or edit the connections available to the user you want.
A connection for that user must be set between the <connection> tags
As shown in this diag:
All the connections from the Selenium Tests(client) should go directly to Selenium HUB, then it will forward the request to an appropriate Node, and return the response.
But what i am observing, that after finding an appropriate Node, the client is trying to communicate directly to the Node.
But in case, the nodes are in a private network and are accesible only by the Selenium HUB and NOT ACCESSIBLE by the Selenium Tests(client) then the subsequent calls fails.
Any idea on how to force all the subsequent calls through the Selenium HUB only?
EDIT
The problem might be something different. My hub is running on 192.168.0.100(with another ip as 10.0.0.2).
So when i am connecting to 192.168.0.100 from my .Net RemoteWebDriverClient, after connecting to the appropriate node, it is using the another ip of the client(10.0.0.2) which is not accessible from my system.
The answer is NO, it doesn't. The Grid remain active throughout the connection.
The ip 10.0.0.2 was of the same selenium HUB machine only. The .net & java implementations of selenium RemoteWebDriver clients were switching to the location header parameter after the initial handshake. This is may be due to the .Net and Java HTTPClient implementations.