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.
Related
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.
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?
I need answer to one very basic question.
Is it necessary to have telnet access to hit an API while systems are connected over VPN? For example, if my system exposed an API for other systems to hit and they are connected in VPN using IPsec, does a third party system needs telnet access to my server for using that API? The API uses soap protocol for receiving request and sending response.
(I did not find out the solution using google. The question is so naive that I had to assume everyone must already know the answer and does not bother to discuss it in web. Sorry for bothering with this simple question)
This is very strange. Accessing an http endpoint for anything else than dev using telnet doesn't really make much sense to me. If someone is using telnet to fetch informations from a server in an application. Something is already really wrong. If telnet is timing out while doing http requests. It's not really your fault and you shouldn't have to worry about edge cases like this.
If the dev is using telnet to discover security issues. This is a different issue and you could probably log anything that come from this particular client. If you gave hime some credentials, it should be easy to find who is doing which request. (I believe you might be already doing this).
You should probably ask the dev "why are you using telnet?". If for whatever reason the dev though he could send a plain SOAP request to your server using telnet without sending HTTP headers and so on.... then yes the connection is likely to timeout because the server isn't going to handle the request.
In my twisted mind, I can imagine some kind of legacy application calling scripts that open telnet sessions to parse some data and return the "parsed" data to the patched legacy project that doesn't handle http/tcp. I'd have in mind some sort of old Cobol application. Much more easier to do system call than to rewrite the whole thing to support APIs.
If for whatever reason, the client claims that telnet is needed for whatever reason. You can tell him back that telnet shouldn't be considered secure. Your api can be accessed using https. As far as I remember telnet doesn't encrypt anything unless you send encrypted data. If your client was able to hack a solution using telnet, I'm pretty sure they can hack a different solution wich use an actual http client.
I have two application written in lift with embedded jetty. The first one is maintaining session based on SessionVar implementation. And that is working great without any problem.
In second application I am using Basic Authentication, which is also working great.
The problem arises when I open both applications in the same browser in different tabs. Even though both applications are running on different ports, the second application causes first to session out.
Does any one have got any idea what's the problem is and how do I resolve this issue?
I am using scala 2.9.0.1 and lift 2.4-M1.
The HTTP port does not affect session management at all. The web server will see them as the same thing. If you want to run them both concurrently, perhaps try accessing one at 127.0.0.1 and the other at localhost, thus negating the issue of them being on the same perceived host.
FWIW, LiftSession is not instantiated at the time of basic authentication; i'm pretty sure its cached by the browser and not by Lift.
I have the need to be able to cycle my linksys router via a program, the reason I want to do this is complex, so let's just assume there is no better option.
Is there anyway to do this? I think there is because when I install a firmware update to the router via the admin console, it cycles the router.
If you can find the function to do that on the router's web interface, you can achieve the same via a suitable HTTP request. Also, you can often telnet to the router and reboot it through its command-line interface. Programmatically you can achieve the same, by using a tool like expect.
If you have access to the local web interface of the router you might be able to access the "reset" function of the router. You can try to call this via a http request, e.g. via wget. But this depends very much on the router. Some routers also support SNMP or a telnet interface.
Another possibility is to plug the router into an ethernet-connected power strip which can be remotely controlled. These power strips usually have a simple http server build in, so you can individually switch on and off the devices that are connected.
If it's a Linksys WRT54G, I highly recommend DD-WRT. It's an open source firmware replacement, and it has this feature built in for timed restarts. A programmatic restart with an HTTP request should be quite easy as well, as the restart function is available through the admin GUI.
https://github.com/danielrussellLA/restart-linksys-EA2700-router you can try using a nightwatch bot similar to this one to programatically restart your router through its browser ui. This works well if your router does not have a command line interface that you can access (through telnet, ssh etc). It's pretty hacky, but it gets the job done.