Connecting to a remote jabber server with a javascript chat client (jsjac) - javascript

This is more of a conceptual question.
I'm trying to create a Javascript jabber client that can be installed on any arbitrary page (on x.com and y.com), and I'd like this client to be able to communicate with a remote jabber server (chatserver.com).
According to the readme of one javascript client I'm lookign at (jsjac), it is an inherent limitation of javascript that it can't communicate with a remote server due to cross site issues.
I'd appreciate hearing from anyone about how to overcome this hurdle. A pointer to an example would be extremely helpful.
[Update] I'm assuming here that I have no control over x.com and y.com, the client servers. The folks at Hab.la seem to have pulled this off, not sure how.

The simplest way around this is to proxy the requests from the JavaScript client to the remote server, via the server that hosts the client.
Apache's mod_proxy extension handles this fine.

Related

Communication with javascript and localhost

I have a JavaScript code running on internet browser and in the same machine in local host is running a python code.
I need to find a way to communicate between them.
Socket client-server is not possible because JavaScript donĀ“t support sockets.
How to Use Sockets in JavaScript\HTML?: "There is no facility to use general-purpose sockets in JS or HTML. It would be a security disaster, for one."
And communication through server not interest me. I need a direct communication on localhost.
Is there any way to communicate with JavaScript and localhost without sockets?
No, by the definition JavaScript cannot use TCP/IP sockets because that would be super super big security hole in the web security model.
You can use
HTTP requests (AJAX)
WebSockets
WebRTC
... to communicate with localhost. The easiest solution is to spin up a SimpleHTTPServer and then make JavaScript AJAX requests against it.
Please note that these communications might not work with HTML files opened file:// and you might need to use a local dev server.
httprelay.io requires no additional libraries and can be used for simple http client to client communication. In your case on browser side use AJAX calls and on Python side use any HTTP client.

Using Javascript to send SSH commands in a browser

My goal is to have a gateway that sends SSH commands to a remote server from a webpage. There are a few browser based extensions, but I wasn't able to find any that were exposed via Javascript. Is there a way to accomplish this client-side without a proxy server in between?
I really don't even need async communications, I really just need a "fire and forget" bucket for SSH calls triggered from a webpage, hopefully without introducing another service somewhere.
You can check out Ajaxterm which is a web based terminal.
also check Orbited which is provides a JavaScript TCP socket API for real-time browser applications.
I hope that help you.

Can you have a Socket.IO (express) server be loaded from a web browser?

You know, a web server. Right now my Socket.IO server loads from a BATCH file that is a JavaScript file. Can you use node and make the socket.io server load from a web browser. Like a web-server utility tool or something of the sort.
That's explicitly not possible due to the design of WebSockets. It starts as a special HTTP request that, after the handshaking, drops the HTTP protocol and strips it down into the WebSocket protocol -- a nearly bare protocol similar to (but slightly more managed than) raw TCP. Because a web browser specifically cannot handle HTTP requests, it could never initiate the socket as a server.
This was done specifically so it wouldn't be possible to write a drive-by botnet website to use scores of users' computers for DDOS attacks without their knowing, amongst other security concerns.
So it wouldn't surprise me if Flash supported that kind of behavior. ;) (I know Java can, but who enables Java applets?)
I'd say you Can. Not that I can think of a good use case.
You would need to put the startup code somewhere where the web server could run it and you would need to get the web server to return some information to the browser to allow it to then connect. You would also have to insert the socket.io code into the browser after the socket server had started.
So I Think that it would indeed be possible but rather complex for little gain. I suppose one possible use case would be to restart a socket server after failure. Actually I'd do that a slightly different way, probably by calling an external script from Node.
fortunatly the answer is no. if you mean by load / launched , NO. but you can create a script on a server that launch another server once a url is requested by a a client.

Best jQuery/Java PHP solution for localhost server - client live chat

I have Apache server with PHP and associated local client PCs in my private network. Can anybody suggest the best chat solution to communicate between client PCs and a server? I am looking for an Ajax/Java solution, like the chat support inside GMail.
Did you consider the XMPP service from google app engine for java?
http://code.google.com/appengine/docs/java/xmpp/
It has very good integration obviously with the rest of google apis and the server can be hosted for free if you're under the quota, or running it on localserver using jetty
You can make use of JQuery / PHP Chat which is free and can be integarted into sites.
Can't do it with Apache. Chat is usually done through a technique called Comet, which is not supported by Apache, AFAIK. GMail uses this technique.
Another, less efficient possibility is using polling strategy, which involves a lot of extraneous server-client communication.

Connecting to a socket via JavaScript (without flash)

I have a browser based app that needs to communicate with another service running on the client machine via a socket connection from the browser using JavaScript.
I need to post and parse XML back and forth on the socket.
I am unable to go down the flash path as the cross domain security is a barrier, ie the service running on the socket is not able to be modified to support Flash's crossdomain security.
What are my options for a pure JS based solution?
You've got two major problems here:
It's difficult in javascript to access non HTTP resources,
It's difficult in javascript to access resources not loaded from the same server.
There are exceptions to both of these, but the conjunction of exceptions available might not exactly match with what you need. Here are some possibilities:
Some sort of proxy on your own server that connects back to the machine with the XML service on behalf of your web app.
If you can control the client machine somewhat you can run a server on it that can embed the XML in a JSONP formatted http response, you can access by adding simple script tags, and send messages the other way by using a script tag to request a url with your data encoded into it.
If when you say 'socket' you're referring to an HTTP connection, then there are a number of options, one is to add a Access-Control-Allow-Origin header to the HTTP, then you can do gets and posts using normal XMLHttpRequests in recent browsers.
Javascript will not allow you to create a socket connection to the client. It would violate the same origin policy. If you could somehow save an applet/swf to the local machine you could serve it up as file:/// and it could communicate to localhost (maybe! not tested).
Maybe creating a proxy to go in front of this unmodifiable socket server could open up some options for you. You could then use something like flash, or you could just not use sockets.
Your options for socket based interaction is limited to plugins that support such live functionality. The options generally break down as follows Flash, Java and Silverlight. All of which aside from Java, if I recall correctly, will have similar policy requirements.
If you control your own server, you could create a socket service to proxy the request to the final destination. Or, depending on the interaction, you can use standard Ajax-style requests and have the socket interaction on your server-side code. If you don't need a persistent connection, having the socket interaction via the server is your best bet.

Categories

Resources