I have a google chrome web extension that needs to communicate with a Qt desktop application - but how?
There is chrome's native messaging, but as I want to support multiple browsers/OS, this would be too much effort because it is only for chrome.
Then there is this post that suggests setting up a local server. This is what I did, see below.
I have set up a server with Qt with QTcpServer that uses QTcpSocket's on 127.0.0.1 (localhost). But a web extension can not listen to sockets, only chrome apps can. There are 2 possible solutions on my mind:
As a workaround, I could perhaps write a small chrome app. The Qt application would talk to the chrome extension via the chrome app (chrome apps support sockets). But I think this method is clumsy and not quite elegant.
On the other hand, I have read about socket.io.
The idea is: The chrome extension talks via http requests with socket.io, and socket.io talks via sockets with my desktop app. Is this a possible solution?
What I also tried, is to directly connect to the local server with the following code. In my Qt server application, I see that there is a new connection. But I can not get a response at all (either my Qt code is wrong or it is because extensions can not listen to sockets?)
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://localhost:12345", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
alert('This is the response from the server: '+ xhr.responseText );
}
as you already know extensions can not create direct connections:
Google Chrome Socket API in extensions
possible solution
maybe your QT application could serve a websocket and you should be able to communicate with that from Javascript:
http://www.html5rocks.com/en/tutorials/websockets/basics/
if you are unable to serve websockets from inside the QT application, another approach could be create a "bridge" a little script that could serve a websocket to your JavaScript and pass the messages from/to the QT application
you will find plenty of examples on websockets, the easy way to get into this could be creating a little server using node.js to play with it stackabuse.com/node-js-websocket-examples-with-socket-io/
oh! and do a search for "websocket same origin policy"
Example of an extension using websockets (that will be useful for debugging): chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en
hope this helps
Related
For one of my application, I have implemented Web socket using socket.io and hosted in IIS. Currently socket connection helping to provide two way connection between client (React) and server (node.js).
As I mentioned, I have hosted my application in IIS. I have few doubts regarding Turn Windows features on or off -> Internet Information services -> World wide Web Services -> Application Development Features -> WebSocket Protocol. I have tested my application without enabling this feature, its working fine, but I would like to confirm below stuffs.
WebSocket Protocol
Do I really need to enable WebSocket protocol feature to make websocket work in my application? If so, how now it is working fine without enabling (I haven't do performance and stress testing, I may face issue on this).
What if I not enabling this feature? in short what is the actual use of this feature?
It would be helpful if anyone answer the above questions. Thanks in advance.
WebSocket as part of the HTTP stack requires a bunch of things to be ready on Windows (across multiple components), so hope this answer helps a little.
HTTP.sys, a driver deep down in Windows OS, is upgraded to support the necessary packet communication required by the protocol.
The IIS WebSocket module, an IIS extension which many other Microsoft frameworks (like SignalR) depend on.
So WebSocket support is by default on in HTTP.sys, and you don't need the IIS module if your framework (socket.io) has no dependency there.
Note that the "Summary" section provides several useful links,
https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support#summary
and the same article also reveals that IIS WebSocket module has
conflicts with socket.io.
I am looking at the features of 1password app which allows us to save a password and access the same data via its mac osx app.
If I was to create an chrome extension for my OSX app - how could it share data with a chrome extension and the Mac App?
Two broad possibilities:
Native Messaging. That's the more secure mechanism, but has only-one-way-to-use-it that essentially means you'll need some "proxy" application that Chrome can start, and that can communicate with your application - it cannot connect to an already-running process.
Local Web(Socket) server. Your native application can open a local port and the extension would try to connect to it and talk this way. Makes it hard to authenticate parties: your extension and your app has no warranties they are not talking to something hostile. Include your own authentication.
See also this question.
FWIW, 1password uses a local WebSocket port.
Is it possible to view the network traffic (http requests, raw http etc.) similar to chrome dev tools (network tab) generated by an application (nodejs if it makes any difference) via vscode?
This functionality is already present, but it doesn't show the requests and responses of the application running.
The developer tools are connected to the running instance of Code and not the application you are executing. Currently it is not possible to view network traffic for the application you are launching from Code.
You can try to start from mbehr1.vsc-webshark plugin and use WireShark tools for catching your app network i/o.
It would be great a more detailed post about configuring launching Rust app (server) in debug mode, wireshark with VSCode integrated UI, and maybe internal browser in a single launch.json action, but I can't point anything close to it.
I need to show to a user an interface of some application running on a server using a browser. It should be like RDP-client for a single application on a server.
Are there any solutions or services that can implement following functionality? Maybe Citrix?
Thanks in advance!
This looks like what you're looking for:
http://freerdp.net/
About FreeRDP-WebConnect
FreeRDP-WebConnect is an open source gateway for accessing RDP
sessions using any HTML5 compliant browser. In particular it relies on
the Canvas and the WebSockets feature. FreeRDP-WebConnect is a
subproject of the FreeRDP project.
On the server side, a standalone daemon - written in C++ - provides a
Web page via HTTPS (or HTTP, if configured) and uses FreeRDP libs to
connect as a client to any RDP session. The server side WebSockets
implementation handles current RFC6455 only, so browsers that
implement the older drafts do not work. With RFC6455 being raised to
the "Proposed Standard" level, this should change now really soon.
I would create an account on the server for the user, and only give it access to the one application it needs access to.
You can use Cameyo. To start, create yourself a free account, and click on "Add App". If your installer supports unattended installation, you simply need to submit it. Otherwise, you can build a Cameyo package locally and send it in. It will then be playable as HTML5.
You don't indicate what server you are running on.
As an alternative to FreeRDP-Webconnect cited above, also open source and also using FreeRDP as rdp client through an HTTP gateway, there is Myrtille.
FreeRDP-WebConnect embeds a standalone daemon written in C++ to provide a web page via HTTP(S), and so will also work on Linux servers, while Myrtille have a IIS/.NET (C#) implementation and an MSI installer, thus is more intended for Windows Servers.
In the tutorial Google provided, they mentioned that you had to use a web server. I want my application to run without an Internet connection. Is this possible?
Yes. You have to set up a web server on your machine though. There are free ones on the Internet:
http://www.google.com/search?rlz=1C1CHKZ_enUS437US437&sourceid=chrome&ie=UTF-8&q=free+web+server&qscrl=1
See this SO question:
stumped on jquery call inside chrome extension
...and here is more information from Google:
http://code.google.com/chrome/extensions/experimental.proxy.html
...and some problems you might run into:
http://osdir.com/ml/chromium-extensions/2011-05/msg00261.html